409006: GYM103414 J Computational ethnography

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Computational ethnographytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Native inhabitants of the L Island write numbers the other way round: most significant digits of a number are written in the end. For instance, number $$$144$$$ is written as $$$441$$$.

Novice ethnographer-mathematician Petya is studying square numbers and the culture of Island L's natives. He noticed that some numbers are perfect squares when considered both as regular numbers and as written by Island L's native inhabitants. For instance, number $$$144$$$ mentioned above is such a number: when considered as written in usual way $$$144 = 12^2$$$ and when considered as number $$$441$$$ written by natives, then $$$441 = 21^2$$$. Petya calls such numbers interesting.

Petya is interested how many interesting numbers there are from $$$A$$$ to $$$B$$$ inclusive.

Input

The first line of input contains integer $$$A$$$, the second line of input contains integer $$$B$$$ ($$$1 \le A \le B \le 10^{11}$$$).

Output

Output the number of interesting numbers from $$$A$$$ to $$$B$$$.

ExampleInput
1
1000
Output
10
Note

In the first sample test interesting numbers are $$$1$$$, $$$4$$$, $$$9$$$, $$$121$$$, $$$144$$$, $$$169$$$, $$$441$$$, $$$484$$$, $$$676$$$ and $$$961$$$. Island L's native inhabitants don't use leading zeros when writing numbers, so $$$100$$$ is not an interesting number.

加入题单

上一题 下一题 算法标签: