import Data.Char

main = do
    w <- getLine
    s <- getContents
    putStrLn $ show $ (length . filter (== (toLowerAll w)))[(toLowerAll x) | x <- (concat . map words . lines) s, x /= f]
        where
            f = "END_OF_TEXT"
            toLowerAll :: String -> String
            toLowerAll s = map toLower s