#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	string s; cin >> s;
	int n = (int)s.size();
	long long ans = 0, cnt = 0;
	for (int i = 0; i < n - 2; ++ i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans += cnt + 1, s[(++ i) + 1] = 'A';
		else if (s[i] == 'A') ++ cnt;
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}