import Data.List
import Data.Char

cntWord word text = length . elemIndices (map toLower word) $ words $ map toLower text
main = do
    word <- getLine
    getContents >>= print . (cntWord word) . unlines . filter (/="END_OF_TEXT") . lines