Count how many times a given digit d appears when writing every integer from 1 to n.
Write down every integer from 1 to nnn in order. Write a program that counts how many times the single digit ddd appears in what you wrote.
For example, with n=11n = 11n=11 and d=1d = 1d=1 you write 1 2 3 4 5 6 7 8 9 10 11. The digit 1 appears once in 1, once in 10, and twice in 11, so its frequency is 4.
The first line contains a natural number nnn (1≤n≤1000001 \le n \le 1000001≤n≤100000) and a single digit ddd (0≤d≤90 \le d \le 90≤d≤9), separated by one space.
Print on the first line how many times the digit ddd appears across all the numbers written from 1 to nnn.