w = gets.chomp.downcase
s = ''
loop do
  line = gets
  break if line.chomp == 'END_OF_TEXT'
  s += line.downcase
end

w_len = w.length
count = 0
(0..s.length).each do |i|
  count += 1 if s[i, w_len] == w
end
puts count