S=input()
ans=0
a=0
for i in range(len(S)):
    if S[i]=="A":
        if i>0 and S[i-1]=="B":
            a=0
        a+=1
    elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
    elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0
print(ans) S=input() S input() input ans=0 ans 0 a=0 a 0 for i in range(len(S)):
    if S[i]=="A":
        if i>0 and S[i-1]=="B":
            a=0
        a+=1
    elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
    elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0 i range(len(S)) range len(S) len S if S[i]=="A":
        if i>0 and S[i-1]=="B":
            a=0
        a+=1
    elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
    elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0 S[i]=="A" S[i] S i "A" if i>0 and S[i-1]=="B":
            a=0
         i>0 and S[i-1]=="B" i>0 i 0 S[i-1]=="B" S[i-1] S i-1 i 1 "B" a=0 a 0 a+=1 a 1 elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
     S[i]=="B" S[i] S i "B" if i>0 and S[i-1]=="B":
            a=0
     i>0 and S[i-1]=="B" i>0 i 0 S[i-1]=="B" S[i-1] S i-1 i 1 "B" a=0 a 0 elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0 S[i]=="C" S[i] S i "C" if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0 i>0 and S[i-1]=="B" i>0 i 0 S[i-1]=="B" S[i-1] S i-1 i 1 "B" ans+=a ans a a=0 a 0 print(ans) print ans a=0 0 a ans+=a a ans a=0 0 a S=input() input() S ans=0 0 ans a=0 0 a a+=1 1 a a=0 0 a
S=input()
ans=0
a=0
for i in range(len(S)):
    if S[i]=="A":
        if i>0 and S[i-1]=="B":
            a=0
        a+=1
    elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
    elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0
print(ans)