bzoj#P3539. [Usaco2014 Open]Odometer

[Usaco2014 Open]Odometer

Statement

Farmer John's cows are on a road trip! The odometer on their car displays an integer mileage value, starting at XX miles at the beginning of their trip and ending at YY miles at the end of their trip. Whenever the odometer displays an 'interesting' number (including at the start and end of the trip) the cows will moo. A number is 'interesting' if when you look at all its digits except for leading zeros, at least half of these should be the same. For example, the numbers 32233223 and 110110 are interesting, while the numbers 9779197791 and 123123 are not. Help FJ count how many times the cows will moo during the trip.

Input Format

Line 11: The first line will contain two integers, XX and YY, separated by a space.

Output Format

Line 11: A single integer containing how many times the cows will moo during the trip.

110 133 

14 

INPUT DETAILS:

The trip starts with the odometer at 110110 and ends at 133133.

OUTPUT DETAILS:

The cows moo when the odometer reads 110110, 111111, 112112, 113113, 114114, 115115, 116116, 117117, 118118, 119119, 121121, 122122, 131131, and 133133.

Constraints

100XY1018100 \le X \le Y \le 10^{18}