Journey Through Worlds
InterviewTime limit2sMemory limit1024 MB
Count the repdigit numbers (such as 11, 222, or 9999) between l and r, where l and r can be as large as 10^18.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Doctor Strange recently gained his powers, but he immediately decided to organize everything. He got access to infinitely many, yet countably many, alternate realities, and he decided to number all of them. Once he finished, he looked at his work and noticed an interesting property of his numbering: all of his favorite alternate realities have numbers made of identical digits, and conversely, every number made of identical digits corresponds to one of his favorite realities.
Of course, Doctor Strange cannot look at all realities at once, so right now he is looking at the realities numbered , , , , . He became curious: how many of his favorite realities is he seeing right now? He has a lot to do and no time to count it himself, so he asked you to help him with this task.
Input
The only line contains two numbers , , the numbers of the outermost alternate realities that Doctor Strange sees ().
Output
Print one line with the number of Doctor Strange's favorite alternate realities that he sees.
Hint
In the first example, all numbers consist of one digit, so they all correspond to favorite realities.
In the second example, the suitable numbers are 11, 22, 33, 44, 55, 66, 77, 88, and 99, which makes exactly 9 of them.