#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
W = gets.chomp.downcase
words = []
while true
    line = gets.chomp
    break if line == 'END_OF_TEXT'
    line.downcase.split.each do |word|
        words.push word
    end
end
puts words.count W