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

solver :: String -> [String] -> Int
solver w t = length $ filter ( == w) (map (map toLower) t)

main :: IO()
main = do
  word <- getLine
  text <- concatMap words . lines <$> getContents
  print $ solver word (text \\ ["END_OF_TEXT"])