Lucky Tickets
Time limit1sMemory limit1024 MB
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 . Dim Dimych noticed that 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: () and (). is the ticket number given to Dim Dimych, and is the number of passengers who boarded before him.
Output
Print one integer, the number of lucky tickets.