시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 120 18 17 18.681%

문제

내 생일이 다가오고 있다. 아아, 나는 늙어가면서 다시 젊어지고 싶었다. 운 좋게도, 나는 어려지는 듯한 기분이 드는 완벽한 방법을 찾았다: 적당한 밑 b를 정해 나이를 적는다면 더 작아 보일 수 있다. 예를 들어, 내 나이가 10진수로 32라면, 16진수로 적는다면 20밖에 되지 않는다!

그러나, 이 방법은 밑을 아무거나 정해서는 할 수 없다. 만약 나이가 0에서 9가 아닌 다른 숫자를 가진다면, 내가 속임수를 쓴다는 것이 명백해지고, 목적을 잃게된다.

추가적으로, 만약 내 나이가 너무 작은 수로 적혀진다면, 그것 또한 명백하게 속임수라는 것이 보일 것이다. 나이 y와 나이가 적어보이고 싶은 하한 l이 주어지면, y를 b진수로 적었을 때 오직 숫자만 포함하고, 이 b진수를 10진수로 읽었을 때 l보다 크거나 같은 최대의 b를 찾아라.

입력

입력은 10진수의 두 정수 y (10 ≤ y ≤ 1018 –네, 많이 늙었습니다)와 l(10 ≤ ℓ ≤ y)로 이루어진 한 줄로 구성된다.

출력

위에서 설명한 최대의 b를 출력하라.

예제 입력 1

32 20

예제 출력 1

16

예제 입력 2

2016 100

예제 출력 2

42
W3sicHJvYmxlbV9pZCI6IjEyNzY5IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjNjAxXHVjNmQwXHVkNTVjIFx1YzgwYVx1Yzc0YyIsImRlc2NyaXB0aW9uIjoiPHA+XHViMGI0IFx1YzBkZFx1Yzc3Y1x1Yzc3NCBcdWIyZTRcdWFjMDBcdWM2MjRcdWFjZTAgXHVjNzg4XHViMmU0LiBcdWM1NDRcdWM1NDQsIFx1YjA5OFx1YjI5NCBcdWIyOTlcdWM1YjRcdWFjMDBcdWJhNzRcdWMxMWMgXHViMmU0XHVjMmRjIFx1YzgwYVx1YzViNFx1YzljMFx1YWNlMCBcdWMyZjZcdWM1YzhcdWIyZTQuIFx1YzZiNCB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