Number Reduction
시간 제한2초메모리 제한256 MB
1부터 N까지의 정수 중, 자기 자신의 1보다 큰 어떤 자릿수로 나누는 과정을 반복해 1에 도달할 수 있는 수의 개수를 센다.
문제
Busy Beaver is given a positive integer () written in base . Then, he repeatedly performs the following operation:
Choose a digit in that is greater than . If is divisible by that digit, divide by that digit. Repeat this process on the resulting number until either is reached or there are no more legal operations. Call valid if there exists a way to reduce it to via this operation.
Compute the number of in the range that are valid.
입력
The first line of input contains the given integer ().
출력
Output a single line, with a single integer equivalent to the number of integers from to that have a way to reach using the operation.
힌트
In the first test case, all integers from to can be divided by themselves to reach , so the answer is .
In the second test case, all integers from to are valid, as mentioned in the first test case. , , and have no digits greater than that are divisors of themselves, and therefore cannot be reduced to . However, can be divided by to get , which can in turn be divided by to get . Therefore, the numbers through and are valid, giving an answer of .