This page is still under construction.

Parts of this page are still being built. What you see may change.

Odometer

Time limit1sMemory limit128 MB

Summary
Count the integers from X to Y with one digit occupying at least half of their decimal digits, ignoring leading zeros.
Level

Medium6 of 10

Topics
Dynamic programming, Combinatorics, Math
Solved
No attempts yet

Problem

The odometer goes from XX to YY. The cows moo whenever it shows an 'interesting' number, including at start and end. A number is interesting if, ignoring leading zeros, at least half of its digits are the same. Examples: 3223 and 110 are interesting; 97791 and 123 are not.

Input

One line with XX and YY (100≤X≤Y≤1018100 \le X \le Y \le 10^{18}).

Output

Print how many times the cows moo.

Examples1

  1. Example 1

    Input
    110 133
    
    Expected output
    14