import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

solve :: String -> Int
solve s = sub s 0
  where
    sub [] n = 0
    sub [x] n = 0
    sub (b:c:s) n = if b == 'B' && c == 'C' then n+(sub s n)
      else if b == 'A' then sub (c:s) (n+1)
        else sub (c:s) 0

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