#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main
if __name__ == '__main__':
    solve() from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys random itertools math sys.setrecursionlimit(10**5) sys.setrecursionlimit sys setrecursionlimit 10**5 10 5 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sqrt = math.sqrt sqrt math.sqrt math sqrt def LI(): return list(map(int, input().split())) LI def LF(): return list(map(float, input().split())) LF def LI_(): return list(map(lambda x: int(x)-1, input().split())) LI_ def II(): return int(input()) II def IF(): return float(input()) IF def S(): return input().rstrip() S def LS(): return S().split() LS II() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) II() II def IR(n): return [II() for _ in range(n)] IR n n LI() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI() LI def LIR(n): return [LI() for _ in range(n)] LIR n n IF() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) IF() IF def FR(n): return [IF() for _ in range(n)] FR n n LI() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI() LI def LFR(n): return [LI() for _ in range(n)] LFR n n LI_() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI_() LI_ def LIR_(n): return [LI_() for _ in range(n)] LIR_ n n S() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) S() S def SR(n): return [S() for _ in range(n)] SR n n LS() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LS() LS def LSR(n): return [LS() for _ in range(n)] LSR n n mod = 1000000007 mod 1000000007 inf = 1e10 inf 1e10 def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main solve s = S() s S() S a = 0 a 0 ans = 0 ans 0 f = 0 f 0 i = 0 i 0 while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

     i < len(s) - 1 i len(s) - 1 len(s) len s 1 if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

     s[i] == "A" s[i] s i "A" a += 1 a 1 i += 1 i 1 elif s[i: i + 2] == "BC":
            ans += a
            i += 2
         s[i: i + 2] == "BC" s[i: i + 2] s i: i + 2 i i + 2 i 2 "BC" ans += a ans a i += 2 i 2 a = 0 a 0 i += 1 i 1 print(ans) print ans return if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve sqrt = math.sqrt math.sqrt sqrt def LIR(n): return [LI() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] LIR def FR(n): return [IF() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] FR def LS(): return S().split() def LS(): return S().split() LS inf = 1e10 1e10 inf def II(): return int(input()) def II(): return int(input()) II def IF(): return float(input()) def IF(): return float(input()) IF def LFR(n): return [LI() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] LFR def LSR(n): return [LS() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] LSR def LI_(): return list(map(lambda x: int(x)-1, input().split())) def LI_(): return list(map(lambda x: int(x)-1, input().split())) LI_ def SR(n): return [S() for _ in range(n)] def SR(n): return [S() for _ in range(n)] SR def IR(n): return [II() for _ in range(n)] def IR(n): return [II() for _ in range(n)] IR def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI input = sys.stdin.readline sys.stdin.readline input def LIR_(n): return [LI_() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] LIR_ def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main solve def LF(): return list(map(float, input().split())) def LF(): return list(map(float, input().split())) LF mod = 1000000007 1000000007 mod def S(): return input().rstrip() def S(): return input().rstrip() S
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    a = 0
    ans = 0
    f = 0
    i = 0
    while i < len(s) - 1:
        if s[i] == "A":
            a += 1
            i += 1
        elif s[i: i + 2] == "BC":
            ans += a
            i += 2
        else:
            a = 0
            i += 1

    print(ans)

    return


#main
if __name__ == '__main__':
    solve()
