import sys



def main():

    input = sys.stdin.readline

    S = input().strip()

    n = len(S)



    T = ''

    i = 0

    while i < n:

        if S[i] == 'A':

            T += 'A'

            i += 1

        elif S[i:i+2] == 'BC':

            T += 'D'

            i += 2

        else:

            T += S[i]

            i += 1



    ans = 0

    cnt = 0

    for c in T:

        if c == 'A':

            cnt += 1

        elif c == 'D':

            ans += cnt

        else:

            cnt = 0



    return ans





if __name__ == '__main__':

    print((main()))

import sys



def main():

    input = sys.stdin.readline

    S = input().strip()

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



    ans = 0

    cnt = 0

    for c in S:

        if c == 'A':

            cnt += 1

        elif c == 'D':

            ans += cnt

        else:

            cnt = 0



    return ans





if __name__ == '__main__':

    print((main()))

import sys


def main():
    input = sys.stdin.readline
    S = input().strip()
    n = len(S)
    T = ""
    i = 0
    while i < n:
        if S[i] == "A":
            T += "A"
            i += 1
        elif S[i : i + 2] == "BC":
            T += "D"
            i += 2
        else:
            T += S[i]
            i += 1
    ans = 0
    cnt = 0
    for c in T:
        if c == "A":
            cnt += 1
        elif c == "D":
            ans += cnt
        else:
            cnt = 0
    return ans


if __name__ == "__main__":
    print((main()))

import sys


def main():
    input = sys.stdin.readline
    S = input().strip()
    S = S.replace("BC", "D")
    ans = 0
    cnt = 0
    for c in S:
        if c == "A":
            cnt += 1
        elif c == "D":
            ans += cnt
        else:
            cnt = 0
    return ans


if __name__ == "__main__":
    print((main()))

-    n = len(S) -    T = "" -    i = 0 -    while i < n: -        if S[i] == "A": -            T += "A" -            i += 1 -        elif S[i : i + 2] == "BC": -            T += "D" -            i += 2 -        else: -            T += S[i] -            i += 1 +    S = S.replace("BC", "D") -    for c in T: +    for c in S: