w = gets.chomp.downcase
res = 0
while line = gets
  break if line.chomp == 'END_OF_TEXT'
  line.chomp.split(' ').each do |ww|
    ww.sub!(/\./, '')
    ww.downcase!
    if ww == w
      res += 1
    end
  end
end
puts res