main :: IO ()
main = do
  w <- getLine
  t <- 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