#include <iostream>

using namespace std;
long long ans,As;
int main(){
    string s;
    cin>>s;
    s = '#'+s+"###";
    for(int i=1;i<=s.length();i++){
        if(s[i] == 'A'){
            As++;
        }else if(s[i] == 'B' && s[i+1]=='C'){
            ans+=As;
            i++;
        }else{
            As = 0;
        }
    }
    cout<<ans<<endl;
}