-- String - Finding a Word

import Data.Char

main :: IO ()
main = do
  w <- getLine
  t <- getContents
  putStrLn . show $ countWord w t

countWord :: String -> String -> Int
countWord w t = length . filter (== w) $ xs
  where xs = map (map toLower) . takeWhile (/= "END_OF_TEXT") . words $ t

