import Control.Applicative
import Control.Monad
import Data.Char

upperCase :: String -> String
upperCase [] = []
upperCase (x:xs)
  | x < 'a' || x > 'z' = x : upperCase xs
  | otherwise          = chr(ord x - ord 'a' + ord 'A') : upperCase xs

main = do
    w <- upperCase <$> getLine
    t <- (map upperCase.words) <$> getContents
    putStrLn $ show(length (filter (==w) t))
    