import sys
s = sys.stdin.readline().rstrip()
N = len(s)

def next_abc(ac, start):
    for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
    return 0, N

ans = ac = i = 0
while i < N:
    ac, i = next_abc(ac, i)
    ans += ac
print(ans) import sys sys s = sys.stdin.readline().rstrip() s sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip N = len(s) N len(s) len s def next_abc(ac, start):
    for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
    return 0, N next_abc for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
     i range(start, N) range start N if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
     ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C' ac and i < N-1 and s[i] == 'B' ac and i < N-1 ac i < N-1 i N-1 N 1 s[i] == 'B' s[i] s i 'B' s[i+1] == 'C' s[i+1] s i+1 i 1 'C' return ac, i+2 return ac, i+2 ac i+2 i 2 elif s[i] == 'A':
            ac += 1
         s[i] == 'A' s[i] s i 'A' ac += 1 ac 1 ac = 0 ac 0 return 0, N return 0, N 0 N ac ac start start ans = ac = i = 0 ans 0 = ac = i = 0 ac 0 i while i < N:
    ac, i = next_abc(ac, i)
    ans += ac i < N i N ac, i = next_abc(ac, i) ac next_abc(ac, i) next_abc ac i i ans += ac ans ac print(ans) print ans i = next_abc(ac, i) next_abc(ac, i) i ac = i = 0 0 ac ac, i = next_abc(ac, i) next_abc(ac, i) ac s = sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() s ans = ac = i = 0 0 ans def next_abc(ac, start):
    for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
    return 0, N def next_abc(ac, start):
    for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
    return 0, N next_abc ans += ac ac ans N = len(s) len(s) N i = 0 0 i
import sys
s = sys.stdin.readline().rstrip()
N = len(s)

def next_abc(ac, start):
    for i in range(start, N):
        if ac and i < N-1 and s[i] == 'B' and s[i+1] == 'C':
            return ac, i+2
        elif s[i] == 'A':
            ac += 1
        else:
            ac = 0
    return 0, N

ans = ac = i = 0
while i < N:
    ac, i = next_abc(ac, i)
    ans += ac
print(ans)