import sys
from collections import Counter

for line in sys.stdin:
    a = input().lower()
    print(Counter(line.lower())[a])