import sys
stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

S = rs()
S = S.replace('BC', 'D')
cnt_A = 0
answer = 0
for s in S:
    if s == 'A':
        cnt_A += 1
    elif s == 'D':
        answer += cnt_A
    else:
        cnt_A = 0
print(answer) import sys sys stdin = sys.stdin stdin sys.stdin sys stdin ri = lambda: int(rs()) ri lambda: int(rs()) int(rs()) int rs() rs rl = lambda: list(map(int, stdin.readline().split())) rl lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split rs = lambda: stdin.readline().rstrip() rs lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip S = rs() S rs() rs S = S.replace('BC', 'D') S S.replace('BC', 'D') S.replace S replace 'BC' 'D' cnt_A = 0 cnt_A 0 answer = 0 answer 0 for s in S:
    if s == 'A':
        cnt_A += 1
    elif s == 'D':
        answer += cnt_A
    else:
        cnt_A = 0 s S if s == 'A':
        cnt_A += 1
    elif s == 'D':
        answer += cnt_A
    else:
        cnt_A = 0 s == 'A' s 'A' cnt_A += 1 cnt_A 1 elif s == 'D':
        answer += cnt_A
     s == 'D' s 'D' answer += cnt_A answer cnt_A cnt_A = 0 cnt_A 0 print(answer) print answer cnt_A = 0 0 cnt_A cnt_A += 1 1 cnt_A stdin = sys.stdin sys.stdin stdin cnt_A = 0 0 cnt_A answer += cnt_A cnt_A answer answer = 0 0 answer S = rs() rs() S S = S.replace('BC', 'D') S.replace('BC', 'D') S ri = lambda: int(rs()) lambda: int(rs()) ri rl = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) rl rs = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() rs
import sys
stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

S = rs()
S = S.replace('BC', 'D')
cnt_A = 0
answer = 0
for s in S:
    if s == 'A':
        cnt_A += 1
    elif s == 'D':
        answer += cnt_A
    else:
        cnt_A = 0
print(answer)