#P5991. [PA 2015] Równanie

[PA 2015] Równanie

Description

For a positive integer nn, define f(n)\operatorname{f}(n) as the sum of the squares of its decimal digits.

Now you are given three positive integers k,a,bk, a, b. Find the number of integers nn such that anba \le n \le b and k×f(n)=nk \times \operatorname{f}(n) = n.

Input Format

The first line contains three positive integers k,a,bk, a, b.

Output Format

Output one integer, the number of integers nn that satisfy the condition.

51 5000 10000
3

Hint

For 100%100\% of the testdata, 1k,a,b10181 \le k, a, b \le 10^{18}, and aba \le b.


Sample Explanation:

The 33 valid values of nn are 72937293, 78547854, and 79057905.

Translated by ChatGPT 5