main :: IO()
main = do
  n <- readLn :: IO Int
  str <- getLine
  let times = findSubStr str
  print times
  where
    findSubStr :: String -> Int
    findSubStr [] = 0
    findSubStr (s:ss) = findABC str + findSubStr ss
      where
        str = [s]++ss
        substr (list) 0 m = take m list
        substr (l:ls) n m = substr ls (n - 1) m
        findABC :: String -> Int
        findABC [] = 0
        findABC str = if (substr str 0 3 == "ABC") then 1 else 0