#include <iostream>
#include <string>
using namespace std;

int main(){
  string s;std::cin>>s;
  long n=0;

  for (int i=0;i<s.size();++i){
    if(s[i]=='B'&&s[i+1]=='C'){
      s.erase(i+1,1);
      s.replace(i,1,"D");
    }
  }
  long a_count=0;
  for (int c=0;c<s.size();++c){
    if (s[c]=='A') ++a_count;
    else if(s[c]=='D') n +=a_count;
    else a_count=0;
  }
  cout << n << endl;
  return 0;
}
