#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
  string S; cin >> S;
  ll ans = 0;
  int cnt = 0;
  rep(i, 0, S.size()-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;
}
