import Control.Applicative ((<$>))
import qualified Data.Char as Char

main = do
    w <- getLine
    t <- getContents
    print $ length $ findWord w t

findWord :: String -> String -> [String]
findWord w t = filter (\x -> w == (Char.toLower <$> x)) $ concat $ words <$> lines t