Problem1530--Counting problem

1530: Counting problem

[Creator : ]
Time Limit : 1 sec  Memory Limit : 128 MB

Description

How many times do the digital X (0 < x < 9) appear in all integers in interval 1 to n? For example, in 1 to 11, that is, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,the digital 1 appear 4 times.

Input

Enter a total of 1 rows, including 2 integers n, x, separated by a space.

Output

The output consists of 1 lines, which contain an integer representing the number of X appearing.

Sample Input Copy

11 1

Sample Output Copy

4

HINT

对于 100%的数据,1≤ n ≤ 1,000,000,0 ≤ x ≤ 9。

 

Source/Category