import sys
input = sys.stdin.readline

s = input()[:-1]
A = 0
ans = 0
i = 0

while i<len(s):
    if s[i]=='A':
        A += 1
        i += 1
    else:
        if i+1<len(s) and s[i:i+2]=='BC':
            ans += A
            i += 2
        else:
            A = 0
            i += 1

print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline s = input()[:-1] s input()[:-1] () input :-1 -1 A = 0 A 0 ans = 0 ans 0 i = 0 i 0 while i<len(s):
    if s[i]=='A':
        A += 1
        i += 1
    else:
        if i+1<len(s) and s[i:i+2]=='BC':
            ans += A
            i += 2
        else:
            A = 0
            i += 1 i<len(s) i len(s) len s if s[i]=='A':
        A += 1
        i += 1
    else:
        if i+1<len(s) and 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 if i+1<len(s) and s[i:i+2]=='BC':
            ans += A
            i += 2
        else:
            A = 0
            i += 1 i+1<len(s) and s[i:i+2]=='BC' i+1<len(s) i+1 i 1 len(s) len s 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 i = 0 0 i ans = 0 0 ans i += 1 1 i input = sys.stdin.readline sys.stdin.readline input ans += A A ans A = 0 0 A A += 1 1 A i += 2 2 i i += 1 1 i s = input()[:-1] input()[:-1] s A = 0 0 A
import sys
input = sys.stdin.readline

s = input()[:-1]
A = 0
ans = 0
i = 0

while i<len(s):
    if s[i]=='A':
        A += 1
        i += 1
    else:
        if i+1<len(s) and s[i:i+2]=='BC':
            ans += A
            i += 2
        else:
            A = 0
            i += 1

print(ans)