s=str(input())
n=len(s)
z=0
ans=0
i=0
while i<=n-2:
    if s[i]=='A':
        z+=1
        i+=1
        continue
    elif s[i:i+2]=='BC' and z>0:
        ans+=z
        i+=2
    else:
        z=0
        i+=1
print(ans) s=str(input()) s str(input()) str input() input n=len(s) n len(s) len s z=0 z 0 ans=0 ans 0 i=0 i 0 while i<=n-2:
    if s[i]=='A':
        z+=1
        i+=1
        continue
    elif s[i:i+2]=='BC' and z>0:
        ans+=z
        i+=2
    else:
        z=0
        i+=1 i<=n-2 i n-2 n 2 if s[i]=='A':
        z+=1
        i+=1
        continue
    elif s[i:i+2]=='BC' and z>0:
        ans+=z
        i+=2
    else:
        z=0
        i+=1 s[i]=='A' s[i] s i 'A' z+=1 z 1 i+=1 i 1 continue elif s[i:i+2]=='BC' and z>0:
        ans+=z
        i+=2
     s[i:i+2]=='BC' and z>0 s[i:i+2]=='BC' s[i:i+2] s i:i+2 i i+2 i 2 'BC' z>0 z 0 ans+=z ans z i+=2 i 2 z=0 z 0 i+=1 i 1 print(ans) print ans s=str(input()) str(input()) s i=0 0 i z=0 0 z n=len(s) len(s) n z+=1 1 z i+=1 1 i ans=0 0 ans ans+=z z ans i+=2 2 i z=0 0 z i+=1 1 i
s=str(input())
n=len(s)
z=0
ans=0
i=0
while i<=n-2:
    if s[i]=='A':
        z+=1
        i+=1
        continue
    elif s[i:i+2]=='BC' and z>0:
        ans+=z
        i+=2
    else:
        z=0
        i+=1
print(ans)