var main = standardInput => {
  var s = standardInput;
  var length = s.length;
  var count = 0;
  s = s.replace(/BC/g,"D")

  var tmpA = 0;
  for(i=0;i<length;i++){
    if(s[i] === "A"){
      tmpA += 1;
    } else if(s[i] === "D"){
      count += tmpA
    } else {
      tmpA = 0;
    }
  }
  console.log(count)
};

main(require("fs").readFileSync("/dev/stdin", "UTF-8"));
