#CCBCHMOT0000022. Số chữ số bằng k (Count Occurrences of Digit K)
Số chữ số bằng k (Count Occurrences of Digit K)
Count Occurrences of Digit K
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative n and digit k (0..9), count occurrences of k in the ordinary decimal representation of n. Zero has exactly one digit, namely 0.
Input
Two integers n and k in this order.
Output
Print how many times digit k occurs.
Subtasks
- Subtask 1 (20%): 0<=n<=9, 0<=k<=9.
- Subtask 2 (30%): 0<=n<=10^6, 0<=k<=9.
- Subtask 3 (50%): 0<=n<=10^18, 0<=k<=9.
Examples
Example 1
Input
10020 0
Output
3
Explanation
The decimal expansion 10020 has three zeros.
Example 2
Input
0 0
Output
1
Explanation
Zero has one zero digit.