#P1362. Rabbit Number Count

    ID: 14649 Type: Default 1000ms 256MiB

Rabbit Number Count

Rabbit Number Count

Define (S(N)) as the sum of the digits of (N); for example, (S(484)=4+8+4=16) and (S(22)=2+2=4). A positive integer (x) is called a Rabbit Number if it satisfies the condition (S(x \cdot x)=S(x)\cdot S(x)). For instance, (22) is a Rabbit Number because (S(22)=4) and (S(484)=16=4\cdot4).

Given an interval ([L,R]), count the number of Rabbit Numbers within the interval.

inputFormat

The input consists of two space-separated integers (L) and (R) representing the inclusive interval.

outputFormat

Output a single integer which is the number of Rabbit Numbers in the interval ([L,R]).

sample

1 10
4