S=input().replace("BC","#")

cnt,point=0,0
for i in range(len(S)):
    if S[i]=="A":point +=1
    elif S[i]=="#":cnt +=point
    else:point=0
print(cnt) S=input().replace("BC","#") S input().replace("BC","#") ().replace () input replace "BC" "#" cnt,point=0,0 cnt 0 point 0 for i in range(len(S)):
    if S[i]=="A":point +=1
    elif S[i]=="#":cnt +=point
    else:point=0 i range(len(S)) range len(S) len S if S[i]=="A":point +=1
    elif S[i]=="#":cnt +=point
    else:point=0 S[i]=="A" S[i] S i "A" elif S[i]=="#":cnt +=point
     S[i]=="#" S[i] S i "#" print(cnt) print cnt cnt,point=0,0 0 cnt S=input().replace("BC","#") input().replace("BC","#") S point=0,0 0 point
S=input().replace("BC","#")

cnt,point=0,0
for i in range(len(S)):
    if S[i]=="A":point +=1
    elif S[i]=="#":cnt +=point
    else:point=0
print(cnt)