{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  getLine
  s <- B.getLine
  print $ solve s

solve :: B.ByteString -> Int
solve = length . B.findSubstrings "ABC"