import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    t = s.replace('BC', 'D')
    
    cnt = 0
    i = 0
    ans = 0
    while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
    print(ans)


if __name__ == '__main__':
    solve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 rl = sys.stdin.readline rl sys.stdin.readline sys.stdin sys stdin readline def solve():
    s = rl().rstrip()
    t = s.replace('BC', 'D')
    
    cnt = 0
    i = 0
    ans = 0
    while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
    print(ans) solve s = rl().rstrip() s rl().rstrip() ().rstrip () rl rstrip t = s.replace('BC', 'D') t s.replace('BC', 'D') s.replace s replace 'BC' 'D' cnt = 0 cnt 0 i = 0 i 0 ans = 0 ans 0 while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
     i < len(t) i len(t) len t if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
         t[i] == 'B' or t[i] == 'C' t[i] == 'B' t[i] t i 'B' t[i] == 'C' t[i] t i 'C' cnt = 0 cnt 0 elif t[i] == 'A':
            cnt += 1
         t[i] == 'A' t[i] t i 'A' cnt += 1 cnt 1 ans += cnt ans cnt i += 1 i 1 print(ans) print ans if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve rl = sys.stdin.readline sys.stdin.readline rl def solve():
    s = rl().rstrip()
    t = s.replace('BC', 'D')
    
    cnt = 0
    i = 0
    ans = 0
    while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
    print(ans) def solve():
    s = rl().rstrip()
    t = s.replace('BC', 'D')
    
    cnt = 0
    i = 0
    ans = 0
    while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
    print(ans) solve
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    t = s.replace('BC', 'D')
    
    cnt = 0
    i = 0
    ans = 0
    while i < len(t):
        if t[i] == 'B' or t[i] == 'C':
            cnt = 0
        elif t[i] == 'A':
            cnt += 1
        else:
            ans += cnt
        i += 1
    print(ans)


if __name__ == '__main__':
    solve()
