key=gets.chomp.downcase
str=""
loop do
   s=gets
   if s.index("END_OF_TEXT")!=nil then break end
   str+=(" "+s.chomp.downcase)
end
pos=0
cnt=0
loop do
      pos=str.index(key,pos+1)
      if pos==nil then break end
      cnt+=1
end
p cnt