S = input()
S = S.replace("BC", "D")
cur = 0
ans = 0
for c in S:
    if c == "A":
        cur += 1
    elif c == "D":
        ans += cur
    else:
        cur = 0
print(ans) S = input() S input() input S = S.replace("BC", "D") S S.replace("BC", "D") S.replace S replace "BC" "D" cur = 0 cur 0 ans = 0 ans 0 for c in S:
    if c == "A":
        cur += 1
    elif c == "D":
        ans += cur
    else:
        cur = 0 c S if c == "A":
        cur += 1
    elif c == "D":
        ans += cur
    else:
        cur = 0 c == "A" c "A" cur += 1 cur 1 elif c == "D":
        ans += cur
     c == "D" c "D" ans += cur ans cur cur = 0 cur 0 print(ans) print ans S = S.replace("BC", "D") S.replace("BC", "D") S cur = 0 0 cur S = input() input() S cur = 0 0 cur cur += 1 1 cur ans += cur cur ans ans = 0 0 ans
S = input()
S = S.replace("BC", "D")
cur = 0
ans = 0
for c in S:
    if c == "A":
        cur += 1
    elif c == "D":
        ans += cur
    else:
        cur = 0
print(ans)
