S = list(input())

ans = 0
cnt = 0
i = len(S)-1
while i >= 0:
    if i > 0 and S[i] == "C" and S[i-1] == "B":
        cnt += 1
        i -= 2
    elif S[i] == "A":
        ans += cnt
        i -= 1
    else:
        cnt = 0
        i -= 1
print(ans) S = list(input()) S list(input()) list input() input ans = 0 ans 0 cnt = 0 cnt 0 i = len(S)-1 i len(S)-1 len(S) len S 1 while i >= 0:
    if i > 0 and S[i] == "C" and S[i-1] == "B":
        cnt += 1
        i -= 2
    elif S[i] == "A":
        ans += cnt
        i -= 1
    else:
        cnt = 0
        i -= 1 i >= 0 i 0 if i > 0 and S[i] == "C" and S[i-1] == "B":
        cnt += 1
        i -= 2
    elif S[i] == "A":
        ans += cnt
        i -= 1
    else:
        cnt = 0
        i -= 1 i > 0 and S[i] == "C" and S[i-1] == "B" i > 0 and S[i] == "C" i > 0 i 0 S[i] == "C" S[i] S i "C" S[i-1] == "B" S[i-1] S i-1 i 1 "B" cnt += 1 cnt 1 i -= 2 i 2 elif S[i] == "A":
        ans += cnt
        i -= 1
     S[i] == "A" S[i] S i "A" ans += cnt ans cnt i -= 1 i 1 cnt = 0 cnt 0 i -= 1 i 1 print(ans) print ans S = list(input()) list(input()) S cnt = 0 0 cnt i = len(S)-1 len(S)-1 i i -= 1 1 i cnt = 0 0 cnt ans += cnt cnt ans i -= 2 2 i cnt += 1 1 cnt i -= 1 1 i ans = 0 0 ans
S = list(input())

ans = 0
cnt = 0
i = len(S)-1
while i >= 0:
    if i > 0 and S[i] == "C" and S[i-1] == "B":
        cnt += 1
        i -= 2
    elif S[i] == "A":
        ans += cnt
        i -= 1
    else:
        cnt = 0
        i -= 1
print(ans)