module Main where

import Data.Functor
import Data.Char

main :: IO ()
main =  do
  { w  <- map toLower <$> getLine
  ; ws <- loop
  ; print $ length $ filter (w ==) ws
  }

loop :: IO [String]
loop = do
  { l <- getLine
  ; if l == "END_OF_TEXT" then return []
    else return . (words (map toLower l) ++) =<< loop
  }