#take the from the user
n=int(input())
#c to save the count of occurence
c=0
#take the element to fin in the no
x=int(input())
#convert the no into string and iterate over each didgit
for i in str(n):
#check if the it is x digit present in the number
if int(i)==x:
#if present increment value of count of occurence
c+=1
print(c)