s = eval(input())

s = s.replace('BC', 'D')



ans = a = 0

for i in s:

    if i == "A":

        a += 1

    elif i == "D":

        ans += a

    else:

        a = 0

print(ans)
import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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



    res = 0

    cnt = 0

    for s in S:

        if s == "A":

            cnt += 1

        elif s == "D":

            res += cnt

        else:

            cnt = 0

    print(res)





if __name__ == '__main__':

    resolve()

s = eval(input())
s = s.replace("BC", "D")
ans = a = 0
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans)

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    S = input().replace("BC", "D")
    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res)


if __name__ == "__main__":
    resolve()

-s = eval(input()) -s = s.replace("BC", "D") -ans = a = 0 -for i in s: -    if i == "A": -        a += 1 -    elif i == "D": -        ans += a -    else: -        a = 0 -print(ans) +import sys + +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    S = input().replace("BC", "D") +    res = 0 +    cnt = 0 +    for s in S: +        if s == "A": +            cnt += 1 +        elif s == "D": +            res += cnt +        else: +            cnt = 0 +    print(res) + + +if __name__ == "__main__": +    resolve()