import Control.Applicative
import Data.List

solver :: String -> [String] -> Int
solver w t =
  let t' = t \\ ["END_OF_TEXT"]
      match = filter (== w) t'
  in
      length match

main :: IO()
main = do
  word <- getLine
  text <- words <$> getContents
  print $ solver word text