
str = gets.chomp
arr = []
while true
  value = gets.chomp.split(" ")
  arr << value
  break if value[0] == "END_OF_TEXT"
end
ans = 0
arr.each do |value|
  value.each do |val2|
    if val2.capitalize == str.capitalize
      ans += 1
    end
  end
end

p ans