def read_inputs
  word = gets.chomp
  article = []
  loop do
    sentence = gets.chomp
    case sentence
      when "END_OF_TEXT" then break
      else article << sentence
    end
  end
  return word, article
end

word, article = read_inputs
puts article.join(" ").upcase.split(word.upcase).length - 1