main = do 
  n <- getLine 
  s <- getLine
  print $ countABC 0 s

countABC :: Int -> String -> Int
countABC c [] = c
countABC c (x:xs) | x == 'A'  = countB c xs
                  | otherwise = countABC c xs 

countB c []                 = c
countB c (x:xs) | x == 'B'  = countC c xs
                | otherwise = countABC c xs

countC c []                 = c 
countC c (x:xs) | x == 'C'  = countABC (c+1) xs
                | otherwise = countABC c xs