S=input()
N=len(S)
i=0
now=0
ans=0
while i<N:
    if S[i]=='A':
        now+=1
    elif S[i:i+2]=='BC':
        ans+=now
        i+=1
    else:
        now=0
    i+=1
print(ans) S=input() S input() input N=len(S) N len(S) len S i=0 i 0 now=0 now 0 ans=0 ans 0 while i<N:
    if S[i]=='A':
        now+=1
    elif S[i:i+2]=='BC':
        ans+=now
        i+=1
    else:
        now=0
    i+=1 i<N i N if S[i]=='A':
        now+=1
    elif S[i:i+2]=='BC':
        ans+=now
        i+=1
    else:
        now=0
     S[i]=='A' S[i] S i 'A' now+=1 now 1 elif S[i:i+2]=='BC':
        ans+=now
        i+=1
     S[i:i+2]=='BC' S[i:i+2] S i:i+2 i i+2 i 2 'BC' ans+=now ans now i+=1 i 1 now=0 now 0 i+=1 i 1 print(ans) print ans now+=1 1 now i+=1 1 i S=input() input() S now=0 0 now i=0 0 i ans=0 0 ans ans+=now now ans i+=1 1 i now=0 0 now N=len(S) len(S) N
S=input()
N=len(S)
i=0
now=0
ans=0
while i<N:
    if S[i]=='A':
        now+=1
    elif S[i:i+2]=='BC':
        ans+=now
        i+=1
    else:
        now=0
    i+=1
print(ans)