Digit frequency

Count how many times a given digit d appears when writing every integer from 1 to n.

Easy3MathImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Write down every integer from 1 to nn in order. Write a program that counts how many times the single digit dd appears in what you wrote.

For example, with n=11n = 11 and d=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.

Input

The first line contains a natural number nn (1n1000001 \le n \le 100000) and a single digit dd (0d90 \le d \le 9), separated by one space.

Output

Print on the first line how many times the digit dd appears across all the numbers written from 1 to nn.