w=gets.chomp
t=""
while true
    str=gets.chomp
    if str=="END_OF_TEXT"
        break
    end
    t+=str
end

tsplit=t.split(/\s/)
cnt=0
tsplit.each { |item|
    if item.casecmp(w)==0
        cnt+=1
    end
}
puts cnt