#P216. 【例36.2】 计数问题

【例36.2】 计数问题

Description

Calculate how many times the digit x (0≤x≤9) appears in all integers from 1 to n. For example, in the range 1 to 11, i.e., in 1,2,3,4,5,6,7,8,9,10,11, the digit 1 appears 4 times.

Input Format

Two integers n and x, separated by a space. For 100% of the data, 1≤n≤1,000,000, 0≤x≤9.

Output Format

A single integer representing the number of times x appears.

Sample

11 1
4