word = gets.chomp.downcase
len = word.size
j = 0

while true
  t = gets.chomp
  break if t=="END_OF_TEXT"  
  t.downcase!
  
  for i in 0..len-1
    if t[i]==word[0]
      for k in 1..len
        break if t[i+k]!=word[k]
        j+=1 if k==len
      end
    end
  end
end

puts j