import sys

readline = sys.stdin.buffer.readline


sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = readline().decode('utf-8')
    S = S.replace('BC', 'D')

    count_a = 0
    ans = 0

    for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans)


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 INF = float('inf') INF float('inf') float 'inf' MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    S = readline().decode('utf-8')
    S = S.replace('BC', 'D')

    count_a = 0
    ans = 0

    for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans) main S = readline().decode('utf-8') S readline().decode('utf-8') ().decode () readline decode 'utf-8' S = S.replace('BC', 'D') S S.replace('BC', 'D') S.replace S replace 'BC' 'D' count_a = 0 count_a 0 ans = 0 ans 0 for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

     s S if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

     s == 'A' s 'A' count_a += 1 count_a 1 elif s == 'D':
            ans += count_a
         s == 'D' s 'D' ans += count_a ans count_a count_a = 0 count_a 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    S = readline().decode('utf-8')
    S = S.replace('BC', 'D')

    count_a = 0
    ans = 0

    for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans) def main():
    S = readline().decode('utf-8')
    S = S.replace('BC', 'D')

    count_a = 0
    ans = 0

    for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans) main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline INF = float('inf') float('inf') INF
import sys

readline = sys.stdin.buffer.readline


sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = readline().decode('utf-8')
    S = S.replace('BC', 'D')

    count_a = 0
    ans = 0

    for s in S:
        if s == 'A':
            count_a += 1
        elif s == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans)


if __name__ == '__main__':
    main()
