import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    s = str(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)


resolve() import sys sys sys.setrecursionlimit(10 ** 5 + 10) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 + 10 10 ** 5 10 5 10 def input(): return sys.stdin.readline().strip() input def resolve():
    s = str(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) resolve s = str(input()) s str(input()) str input() input s = s.replace('BC', 'D') s s.replace('BC', 'D') s.replace s replace 'BC' 'D' ans = a = 0 ans 0 = a = 0 a 0 for i in s:
        if i == 'A':
            a += 1
        elif i == 'D':
            ans += a
        else:
            a = 0
     i s if i == 'A':
            a += 1
        elif i == 'D':
            ans += a
        else:
            a = 0
     i == 'A' i 'A' a += 1 a 1 elif i == 'D':
            ans += a
         i == 'D' i 'D' ans += a ans a a = 0 a 0 print(ans) print ans resolve() resolve def resolve():
    s = str(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) def resolve():
    s = str(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) resolve def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    s = str(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)


resolve()