import Data.Char(toLower)
main = do
  t <- getLine
  ss <- getContents
  let s = unwords $ takeWhile (/="END_OF_TEXT") $ words ss
  putStrLn $ show (solve s t)
  
solve :: String -> String -> Int
solve s t'= let v=words $ map toLower s
                t = map toLower t' in
            (length . filter (==t)) v