import Data.List
import Data.Maybe

findString :: (Eq a) => [a] -> [a] -> Maybe Int
findString search str = findIndex (isPrefixOf search) (tails str)

sol s
    | isNothing i = 0
    | otherwise   = 1 + (sol $ drop (fromJust i + 3) s)
    where
        i = findString "ABC" s

main=do
    _ <- getLine
    s <- getLine
    print $ sol s
