Back
Close
  • 62

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

Count the number of times the digit k appears in all non-negative integers less than or equal to a given integer n.
Input
Line 1: A single integer n, the upper bound for counting occurrences of the digit k.
Line 2: A single integer k.
Output
Line 1 : A single integer representing the total number of times the digit k appears in all non-negative integers less than or equal to n.
Constraints
0 ≤ n ≤ 10^9
1 ≤ k ≤ 9
Example
Input
12
2
Output
2

A higher resolution is required to access the IDE