#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003;
int n, tmp;
LL ans;
char s[N];
int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(Rint i = 1;i <= n;i ++){
		if(s[i] == 'A') ++ tmp;
		else if(s[i] == 'B' && s[i + 1] == 'C'){
			ans += tmp;
			++ i;
		} else tmp = 0;
	}
	printf("%lld", ans);
}