import Data.Char

lowerCase [] = []
lowerCase (ch:ss) = toLower ch : lowerCase ss

main = do
  w <- return . lowerCase =<< getLine
  t <- return . filter (/= "END_OF_TEXT") . concat . map words . lines =<< getContents
  print $ length $ filter (== w) $ map lowerCase t