#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	ll n=s.size();
	ll cnt=0,ans=0;
	rep(i,n){
		if(s[i]=='A')cnt++;
		else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=cnt;
			i++;
		}
		else cnt=0;
	}
	cout<<ans<<endl;
}
