#B4007. Counting Occurrences of a Lucky Digit
Counting Occurrences of a Lucky Digit
Counting Occurrences of a Lucky Digit
Little Yang considers his lucky number to be a positive integer \( k \) (with the guarantee \( 1 \le k \le 9 \)). He is curious to know how many times the digit \( k \) appears in all positive integers from 1 to \( n \). For example, if \( k=3 \) and \( n=35 \), the digit 3 appears 10 times.
Your task is to count the total number of occurrences of the digit \( k \) when listing every integer from 1 through \( n \).
inputFormat
The input consists of a single line with two space-separated integers: the lucky digit \( k \) (\( 1 \le k \le 9 \)) and the integer \( n \).
outputFormat
Output a single integer representing the total number of times digit \( k \) appears in all the numbers from 1 to \( n \).
sample
3 35
10