import Data.Char
readEnd :: IO String
readEnd = do
  l <- getLine
  if l == "END_OF_TEXT" then return ""
  else do
    ln <- readEnd
    return (l ++ "\n" ++ ln)

main = do
  w <- getLine
  c <- readEnd
  putStrLn . show . length . filter (==w) . words . map toLower $ c