import Data.Char

solve :: String -> String -> Int
solve s w = length $ filter (\x -> map toLower x == lw) $ takeWhile (\x -> x /= "END_OF_TEXT") $ words s
    where lw = map toLower w

main :: IO ()
main = do
    w <- getLine
    s <- getContents
    putStrLn $ show $ solve s w