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 = -1
while true
    i = longstr.index(str, i+1)
    break if i == nil
    c += 1
end

puts c