#K86817. Counting Character Occurrences
Counting Character Occurrences
Counting Character Occurrences
In this problem, you are given a string S and a character c. Your task is to count and output the number of occurrences of c in S.
The solution should read inputs from standard input (stdin) and print the result to standard output (stdout).
In mathematical notation, if we denote by \(f(S, c)\) the number of times character \(c\) appears in string \(S\), then
\[ f(S, c) = \sum_{i=1}^{|S|} \mathbf{1}_{\{S_i = c\}}, \]
where \(\mathbf{1}_{\{S_i = c\}}\) is 1 if \(S_i = c\) and 0 otherwise.
inputFormat
The input consists of two lines:
- The first line contains a non-empty string S.
- The second line contains a single character c whose occurrences in S are to be counted.
Note: The string may contain spaces and punctuation.
outputFormat
Output a single integer representing the number of times the character c appears in the string S.
## samplehello
l
2