#C7284. Count Character Occurrences

    ID: 51138 Type: Default 1000ms 256MiB

Count Character Occurrences

Count Character Occurrences

Given a string s and a character c, count the number of times c appears in s. The matching is case-sensitive.

The input is provided via standard input. The first line contains the string s, and the second line contains the single character c. You should output the result to standard output.

For example, if the input is:

hello
l

then the output should be:

2

Use the following formula to represent the answer if needed:

\(\text{result} = \sum_{i=0}^{|s|-1} [s_i = c]\)

inputFormat

The input consists of two lines:

  • The first line is a string s of length at most 1000.
  • The second line is a single character c.

Both inputs are read from standard input.

outputFormat

Output a single integer which is the number of times the character c appears in the string s. The result should be printed to standard output.

## sample
hello
l
2