import Data.Char (toLower)
import Control.Monad (liftM)
    
main :: IO ()
main = do
  w <- liftM (map toLower) getLine
  t <- liftM (map toLower) getContents
  print $ countWord w $ concatMap words $ init (lines t)

countWord :: String -> [String] -> Integer
countWord w = foldr (\x acc -> if x == w then acc + 1 else acc) 0