
def count(w, s)
  cnt = 0
  p = -1
  while p = s.index(w, p+1)
    cnt += 1
  end
  cnt
end

w = gets.chomp
ans = 0
loop do
  s = gets.chomp
  break if s == "END_OF_TEXT"
  ans += count(w, s)
end

puts ans