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