// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



using ll = long long int;

using llu = unsigned long long int;

using ld = long double;

const long long int NUM = 1000000;

const long double PI = 2*acos(0.0);

const int INF = 1e9 + 10 ;

const long long int maximum = (-1*INF);

#define LCM(a,b)            (a / __gcd(a,b)) * b

#define GCD(a,b)            __gcd(a,b)

#define dist(x1,y1,x2,y2)   sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define sqr(a)              ((a)*(a))

#define fast                ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

#define precision(a)        fixed<<setprecision(a)

#define endl                "\n"

#define pb                  push_back

#define bp                  pop_back

#define pf                  push_front

#define fp                  pop_front

#define mp                  make_pair

#define ff                  first

#define ss                  second

#define ub                  upper_bound

#define lb                  lower_bound

#define all(x)              x.begin(), x.end()

#define debug(x)            cout<<"debug "<<x<<"\n"

#define ms(a,b)             memset((a),(b),sizeof(a))

#define min3(a,b,c)         min(a,min(b,c))

#define max3(a,b,c)         max(a,max(b,c))

#define min4(a,b,c,d)       min(min(a,b),min(c,d))

#define max4(a,b,c,d)       max(max(a,b),max(c,d))

#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))

#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))

#define REP(i,b)            for(long long int i = 0; i < b; i++)

#define READ(f)             freopen("f", "r", stdin)

#define WRITE               freopen("out.txt", "w", stdout)



/*void sieve(ll n) {

    bool status[(n>>1)+1] = {false};

    ll inc, i;

    for(i = 3; i*i <= n; i += 2)

    {

        if(!status[i>>1])

        {

            inc = i<<1;

            for(ll j = i*i; j <= n; j += inc)

                status[j>>1] = true;

        }

    }

}*/



/*struct A {

    ll a;

    ll low;

    ll high;

};*/



/*bool compare(A x, A y)

{

    if(x.high == y.high) {

        if (x.low == y.low)

            return x.a <= y.a;

        return x.low > y.low;

    }

    return x.high > y.high;

}*/



/*ll logs(ll x)

{

    return 64 - __builtin_clzll(x) - 1;

}*/



//map<char, ll> m = { {'q', 9}, {'r', 5}, {'b', 3}, {'n', 3}, {'p', 1}, {'k', 0}, {'.', 0} };



//||



int main() {

    fast;

    string s;

    cin >> s;

    ll cntA, cnt, sum = 0;

    ll prev = 0;

    ll n = s.size();

    for (ll i = 0; i < n-2; i++) {

        cnt = 0; cntA = 0;

        if (s[i] != 'A') prev = 0;

        else if (s[i] == 'A') {

            cntA = prev;

            for (; i < n-2; i++) {

                if (s[i] != 'A')

                    break;

                cntA++;

            }

            if (s[i] == 'B' && s[i+1] == 'C') {

                for (; i < n-1; i += 2) {

                    if (s[i] == 'B' && s[i+1] == 'C')

                        cnt++;

                    else break;

                }

                sum += cnt * cntA;

                //debug(sum);

                prev = cntA;

            }

            i--;

        }

    }

    cout << sum;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;



char s[200002];

int z[200001];

int main(){

	scanf("%s",s+1);

	int n=strlen(s+1);

	for(int i=1;i<=n;i++)

		if(s[i]=='A')z[++z[0]]=1;

		else if(i<n&&s[i]=='B'&&s[i+1]=='C')

			z[++z[0]]=2,i++;

		else z[++z[0]]=3;

	long long ans=0;

	for(int i=1;i<=z[0];i++){

		if(z[i]==3)continue;

		int j=i;

		while(j<=z[0]&&z[j]!=3)j++;

		int w=0;

		for(int k=i;k<=j;k++)

			if(z[k]==2)ans+=k-i-w,w++;

		i=j;

	}

	printf("%lld\n",ans);

}

// Fastest known solution for this problem: