#include<bits/stdc++.h>
using namespace std;

#define int long long
int tmp, ans;

signed main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'A') tmp++;
        else if(s[i] == 'C') tmp = 0;
        else if(s[i] == 'B' && s[i + 1] != 'C') tmp = 0;
        else{
            ans += tmp;
            i++;
        }
    }
    cout << ans;
}