All problems

Problem 789

Count a Character in a String

Easy · 10 pts · String, Basics

Problem

Count how many times the character C appears in the string S. The comparison is exact, so uppercase and lowercase letters are different characters (A is not a). Loop over the characters of S and add one whenever a character equals C. The answer is 0 if C does not appear.

Input

The first line contains S. The second line contains the single character C. Both use English letters.

Output

Print the number of times C appears in S.

Constraints

1 <= |S| <= 100000

Example input

mississippi
s

Example output

4

Explanation

In mississippi the letter s appears at four positions, so for C = s the answer is 4.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Remove Vowels from a String Next: Equal Strings Ignoring Case