Counting a Digit
How many times does the digit D appear when all integers 1..N are written out?
Input: one line with two integers N and D.
Output: the number of occurrences of digit D in 1..N.
Constraints:
- 1 ≤ N ≤ 1018
- 0 ≤ D ≤ 9
Sample Tests
Input 1
13 1
Output 1
6
Input 2
25 2
Output 2
9
Discussion (opens after you solve — no spoilers before)
No comments yet.