import Control.Applicative
import Data.Function
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    w <- getLine
    s <- map (map toLower) . words <$> getContents
    putStrLn . show $ length $ filter (== w) s
