longstr = " "
str = " " + gets.chomp.upcase + " "
while true
    d = gets.chomp
    break if d == "END_OF_TEXT"
    longstr += d + " "
end
longstr = longstr.upcase

c = 0
i = -(str.length-2)
while true
    i = longstr.index(str, i+(str.length-2))
    break if i == nil
    c += 1
end

puts c