10161016 SUSTech Online Judge
Problem 1016 --CS203 Lucky numbers

1016: CS203 Lucky numbers

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 878  Solved: 122
[Submit][Status][Web Board]

Description

Cuperman defines CS203 Lucky number as that if you rotate the number 180 degrees the number will not change. For example, 69, 96, 111, 181 are lucky numbers. 87, 76 are not.(0, 1, 8 will not change in this way, 6 will change into 9, 9 will change into 6. 2 and 5 can't change to each other) Now Cuperman wants to know the number of CS203 lucky number between range L and R, so she asked Huang Bo, as you know, Huang Bo is lazy, he wants you to solve this problem!

Input

 There are multiple test cases(less than 10), each test will contain two integers L and R.

Notice the range of L and R is 0 <= L <= R <= 1012

Output

A single line for each test case, represent the number of lucky number in [L, R].

Sample Input

50 100

Sample Output

3

HINT

Hard problem. Try to use recursion.

Source

[Submit][Status]