s=list(input())
S=[]
n=0
while n+1<len(s):
    if s[n:n+2]==["B","C"]:
        S.append("D")
        n+=1
    else:
        S.append(s[n])
    n+=1
a=0
ans=0
for i in range(len(S)):
    if S[i]=="D":
        ans+=a
    elif S[i]=="A":
        a+=1
    else:
        a=0
print(ans) s=list(input()) s list(input()) list input() input S=[] S [] n=0 n 0 while n+1<len(s):
    if s[n:n+2]==["B","C"]:
        S.append("D")
        n+=1
    else:
        S.append(s[n])
    n+=1 n+1<len(s) n+1 n 1 len(s) len s if s[n:n+2]==["B","C"]:
        S.append("D")
        n+=1
    else:
        S.append(s[n])
     s[n:n+2]==["B","C"] s[n:n+2] s n:n+2 n n+2 n 2 ["B","C"] "B" "C" S.append("D") S.append S append "D" n+=1 n 1 S.append(s[n]) S.append S append s[n] s n n+=1 n 1 a=0 a 0 ans=0 ans 0 for i in range(len(S)):
    if S[i]=="D":
        ans+=a
    elif S[i]=="A":
        a+=1
    else:
        a=0 i range(len(S)) range len(S) len S if S[i]=="D":
        ans+=a
    elif S[i]=="A":
        a+=1
    else:
        a=0 S[i]=="D" S[i] S i "D" ans+=a ans a elif S[i]=="A":
        a+=1
     S[i]=="A" S[i] S i "A" a+=1 a 1 a=0 a 0 print(ans) print ans S=[] [] S n+=1 1 n a=0 0 a n=0 0 n n+=1 1 n ans+=a a ans a+=1 1 a ans=0 0 ans a=0 0 a s=list(input()) list(input()) s
s=list(input())
S=[]
n=0
while n+1<len(s):
    if s[n:n+2]==["B","C"]:
        S.append("D")
        n+=1
    else:
        S.append(s[n])
    n+=1
a=0
ans=0
for i in range(len(S)):
    if S[i]=="D":
        ans+=a
    elif S[i]=="A":
        a+=1
    else:
        a=0
print(ans)