Almost Favorite Numbers
InterviewTime limit0.5sMemory limit1024 MB
Count the integers from 1 to m whose decimal representation ends with the digits of n.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Deadpool is very fickle, so his favorite number changes every day. Since he has only one at a time, he invented the idea of an "almost favorite number" for the times when he needs several numbers.
A number is almost favorite if its decimal representation ends with Deadpool's favorite number. For example, if the favorite number is , then , , and are almost favorite, while and are not.
Deadpool hates limits, but this world cannot do without them. He needs a program that counts the almost favorite numbers not exceeding .
Deadpool has many orders, so please help him write this program.
Input
The single line of the input file contains two integers and (): Deadpool's favorite number and the upper bound on the size of an almost favorite number.
Output
Print one integer: the number of almost favorite numbers not exceeding .