function Main(input) {
    var S = input.trim();
    S = S.replace(/BC/g,"D");
    var N = S.length;
    var output = 0;
    var Acount = 0;
    for(var i = 0; i < N; i++){
        if(S[i] == "A"){
            Acount++;
        }
        else if(S[i] == "D"){
            output += Acount;
        }
        else{
            Acount = 0;
        }
    }
    console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));