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

main :: IO ()
main = do
  (word:text) <- takeWhile (/= "END_OF_TEXT") . lines <$> getContents
  print (length $ filter (== (map toLower word)) (concatMap (map (map toLower) . words) text))

