John's Test
Small John is testing numbers using two integers, A
and B
. For any integer X
, if A ≤ X ≤ B
, then X
passes John's test. If not, John rearranges the digits of X
to form a new integer Y
. He constructs Y
by taking the first digit of X
, then the last digit, followed by the second digit, the second-to-last digit, and so on, until all digits are used. For instance, if X = 1234567
, then Y = 1726354
, and if X = 1020
, then Y = 1002
. If A ≤ Y ≤ B
, then X
passes the test; otherwise, it does not.
Your task is to determine how many positive integers pass John's test.
Input
Two integers A
and B
, separated by a space.
Output
The count of positive integers that pass the test.
Constraints
1 ≤ A ≤ B ≤ 1000000000000000000 (10^18).
Notes
In the first example, the numbers 98
, 99
, 100
, 101
, 102
, 110
, and 120
pass John's test.