str = input().replace(" ","").upper() #不区分大小写,全转化成大写进行匹配
x = input().upper()
a = 0
for c in str:
    if c==x: a+=1
print(a)