import           Control.Exception (assert)
import           Data.List         (tails)

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  assert (length s == n) $
    print $ solve s

solve :: String -> Int
solve = length . filter (\s -> take 3 s == "ABC") . tails
