module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: String -> [String] -> Int
solve w = iter where
    iter [] = 0
    iter (s:ss) = count (==w) (words (map toLower s)) + iter ss where
        count _ [] = 0
        count f (x:xs) = (if f x then 1 else 0) + count f xs

readUntil :: (String -> Bool) -> IO [String]
readUntil eof = iter where
    iter = getLine >>=
            (\a -> if eof a then return [] else fmap (a:) iter)

eof :: String -> Bool
eof s = s == "END_OF_TEXT"

main :: IO() 
main = do
    w <- getLine
    l <- readUntil eof
    print (solve w l)
