Infinity Triples
시간 제한4초메모리 제한2048 MB
1 ≤ a < b ≤ m이고 n ≤ m인 삼중항 (n, a, b) 중에서 밑 b의 반복 숫자 a, aa, aaa... 가 무한히 많이 n으로 나누어떨어지는 것의 개수를 센다.
문제
Consider numbers in base where all digits are equal to with . We call a triple an infinity triple if infinitely many of those numbers are divisible by .
For example, is an infinity triple because infinitely many of the numbers , , , are divisible by . The triple is also an infinity triple, but is not.
Given , count the number of infinity triples with and .
입력
The input contains one integer ().
출력
Output one integer, the number of infinity triples with and .
힌트
In the first sample, is the only infinity triple.
In the second sample, the infinity triples are and .