#!/usr/bin/env ruby
require "pp"

search_word = gets.chomp
strings = []

while strings[-1] != "END_OF_TEXT" do
    strings.concat(gets.split(/\W/))
end
count = 0
strings.each do |word|
    if word == search_word then
        count += 1
    end
end
puts count

