import Data.Char (toLower)

strToLower :: String -> String
strToLower = map toLower

main :: IO ()
main = do
    word <- getLine >>= return . strToLower
    getContents >>= return . strToLower >>= print . length . filter (==word) . takeWhile (/="END_OF_TEXT") . words
