import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

main = do
    w <- map toLower <$> getLine
    t <- map (map toLower) . takeWhile (/="END_OF_TEXT"). words <$> getContents
    print . length . filter (==w) $ t