#P1362. 兔子数

兔子数

Description

Let S(N)S(N) denote the sum of the digits of NN, such as S(484)=4+8+4=16S(484) = 4+8+4 = 16, S(22)=2+2=4S(22) = 2+2 = 4. If a positive integer satisfies S(xx)=S(x)S(x)S(x \cdot x) = S(x) \cdot S(x), we call it a Rabbit Number. For example, 2222 is a Rabbit Number, because S(484)=S(22)S(22)S(484) = S(22) \cdot S(22).

Now, given an interval [L,R][L,R], find the number of Rabbit Numbers within this interval.

Input Format

The input consists of a single line with two numbers LL and RR separated by a space.

Output Format

Output a single line containing one integer, the number of Rabbit Numbers in [L,R][L,R].

22 22

1

484 484

0
1 58

12
58 484

24
1000000000 1000000000

1

Hint

Constraints: For 100%100 \% of the testdata, 1LR1091 \le L \le R \le 10^9.

Translated by ChatGPT 5