S = input()
s = S.replace("BC", "X")
ans = 0
a = 0
for c in s:
    if c == "A":
        a += 1
    elif c == "X":
        ans += a
    else:
        a = 0

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

print(ans)