#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll cnt=0,ans=0;
    rep(i,n-1){
        if(s[i]=='A')cnt++;
        else if(s[i]=='B'&&s[i+1]=='C'){ans+=cnt; i++;}
        else cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}