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

int main(){
  string s; cin>>s;

  long long ans=0LL; int bc=0;
  for(int i=s.size()-2; i>=0; --i){
    if(s[i]=='A'&&s[i+1]!='C')ans+=bc;
    else if(s[i]=='C'&&s[i+1]=='A')continue;
    else if(s[i]=='C'&&s[i+1]=='B')continue;
    else if(s[i]=='B'&&s[i+1]=='C')++bc;
    else bc=0;
  }

  cout<<ans<<endl;
}
