word = gets.chomp.downcase
words = Array.new
while true do
  begin
    buf_word = gets.chomp.gsub(/[^A-Za-z\s]/,'').downcase.split
  rescue
    words.pop
    break
  end
  #break if buf_word[0] == 'end_of_text'
  words.concat(buf_word);
end

puts words.count word