import Data.Char

solve :: String -> String -> Int
solve w t = count w $ words t

count :: (Eq a) => a -> [a] -> Int
count needle list = foldl (\acc x -> if x == needle then acc + 1 else acc) 0 list

main = do
	w <- fmap (map toLower) getLine
	t <- fmap (map toLower) getContents
	putStrLn $ show $ solve w t