s=list(input())
n=len(s)
S=[]
t=0
while t<n-1:
    if s[t]=='B' and s[t+1]=='C':
        S.append('R')
        t+=1
    else:
        S.append(s[t])
    t+=1
if t==n-1:
    S.append(s[t])
m=len(S)
amount=0
bc=0
a=0
for i in range(m):
    if S[i]=='A':
        a += 1
    elif S[i]=='R':
        amount += a
        bc=1
    else:
        a=0
        bc=0
print(amount) s=list(input()) s list(input()) list input() input n=len(s) n len(s) len s S=[] S [] t=0 t 0 while t<n-1:
    if s[t]=='B' and s[t+1]=='C':
        S.append('R')
        t+=1
    else:
        S.append(s[t])
    t+=1 t<n-1 t n-1 n 1 if s[t]=='B' and s[t+1]=='C':
        S.append('R')
        t+=1
    else:
        S.append(s[t])
     s[t]=='B' and s[t+1]=='C' s[t]=='B' s[t] s t 'B' s[t+1]=='C' s[t+1] s t+1 t 1 'C' S.append('R') S.append S append 'R' t+=1 t 1 S.append(s[t]) S.append S append s[t] s t t+=1 t 1 if t==n-1:
    S.append(s[t]) t==n-1 t n-1 n 1 S.append(s[t]) S.append S append s[t] s t m=len(S) m len(S) len S amount=0 amount 0 bc=0 bc 0 a=0 a 0 for i in range(m):
    if S[i]=='A':
        a += 1
    elif S[i]=='R':
        amount += a
        bc=1
    else:
        a=0
        bc=0 i range(m) range m if S[i]=='A':
        a += 1
    elif S[i]=='R':
        amount += a
        bc=1
    else:
        a=0
        bc=0 S[i]=='A' S[i] S i 'A' a += 1 a 1 elif S[i]=='R':
        amount += a
        bc=1
     S[i]=='R' S[i] S i 'R' amount += a amount a bc=1 bc 1 a=0 a 0 bc=0 bc 0 print(amount) print amount s=list(input()) list(input()) s amount += a a amount a += 1 1 a t+=1 1 t a=0 0 a a=0 0 a m=len(S) len(S) m bc=0 0 bc amount=0 0 amount bc=1 1 bc n=len(s) len(s) n bc=0 0 bc S=[] [] S t=0 0 t t+=1 1 t
s=list(input())
n=len(s)
S=[]
t=0
while t<n-1:
    if s[t]=='B' and s[t+1]=='C':
        S.append('R')
        t+=1
    else:
        S.append(s[t])
    t+=1
if t==n-1:
    S.append(s[t])
m=len(S)
amount=0
bc=0
a=0
for i in range(m):
    if S[i]=='A':
        a += 1
    elif S[i]=='R':
        amount += a
        bc=1
    else:
        a=0
        bc=0
print(amount)