#include <bits/stdc++.h>
const int maxn=2e5+7;
int n;
char s[maxn];
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	int cnt=0;long long ans=0;
	for(int i=1;i<=n;)
		if(s[i]=='A')++cnt,++i;
		else if(s[i]=='B' && s[i+1]=='C')
			ans+=cnt,i+=2;
		else cnt=0,++i;
	printf("%lld\n",ans);
	return 0;
}
