Under construction

Still being built. Things may change

Lucky Tickets

Time limit1sMemory limit1024 MB

Summary
Count the tickets with all-equal digits in the range from N-M to N, where N is Dim Dimych's ticket and M is the number of earlier passengers.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Dim Dimych is riding a bus. Every passenger receives a ticket when boarding, and each ticket has a number from 1 to 10910^9. Dim Dimych noticed that MM passengers boarded the bus before him. The ticket number given to each next passenger is always exactly 1 more than the ticket number given to the previous passenger. A lucky ticket is a ticket whose number has all digits the same. Dim Dimych wonders how many passengers on the bus have lucky numbers. Help him find out.

Input

The input file has one line with two numbers separated by a space: NN (1≤N≤1091 \le N \le 10^9) and MM (0≤M≤1090 \le M \le 10^9). NN is the ticket number given to Dim Dimych, and MM is the number of passengers who boarded before him.

Output

Print one integer, the number of lucky tickets.

Examples1

  1. Example 1

    Input
    1000 999
    
    Expected output
    27