import Control.Applicative
import Data.List
import Data.Char

deleteChrFromStr :: Char -> String -> String
deleteChrFromStr chr str = if elem chr str then deleteChrFromStr chr (delete chr str) else str

deleteComma str = deleteChrFromStr ',' str
deletePeriod str = deleteChrFromStr '.' str
deleteLF str = deleteChrFromStr '\n' str
deleteDoubleQuotation str = deleteChrFromStr '"' str

strLower []     = ""
strLower (x:xs) = (toLower x) : (strLower xs)

countElem elm []     = 0
countElem elm (x:xs) = (if x==elm then 1 else 0) + (countElem elm xs)

main = do{
    word <- getLine;
    count <- countElem word . map (strLower . deleteComma . deletePeriod . deleteLF . deleteDoubleQuotation) . words <$> getContents;
    print $ count;
}