import           Control.Applicative
import           Data.Char
import           Data.List

main :: IO ()
main = do
    w <- getLine
    xs <- concatMap words . lines . fmap toLower <$> getContents
    print $ length $ filter (== w) xs

