import Data.List
import Data.Char

main = interact $ show' . solve . read'
  where
    show' x = (show x) ++ "\n"
    solve (word, words) = count word words 0
    count word [] acc = acc
    count word (x:xs) acc | word == x = count word xs (acc + 1)
                          | otherwise = count word xs acc
      where l = length word
    read' = f . lines
      where f (x:xs) = ([toLower c | c <- x], words [toLower c | c <- (unlines xs)])

