S = list(input())
N = len(S)
lst = []
l = []
i = 0
while i < N:
    if S[i] == 'A':
        l.append(0)
        i += 1
    elif S[i] == 'B' and i+1 < N and S[i+1] == 'C':
        l.append(1)
        i += 2
    else:
        lst.append(l)
        l = []
        i += 1
if len(l):
    lst.append(l)
ans = 0
for l in lst:
    cnt = 0
    for x in l:
        if x == 0:
            cnt += 1
        else:
            ans += cnt
print(ans) S = list(input()) S list(input()) list input() input N = len(S) N len(S) len S lst = [] lst [] l = [] l [] i = 0 i 0 while i < N:
    if S[i] == 'A':
        l.append(0)
        i += 1
    elif S[i] == 'B' and i+1 < N and S[i+1] == 'C':
        l.append(1)
        i += 2
    else:
        lst.append(l)
        l = []
        i += 1 i < N i N if S[i] == 'A':
        l.append(0)
        i += 1
    elif S[i] == 'B' and i+1 < N and S[i+1] == 'C':
        l.append(1)
        i += 2
    else:
        lst.append(l)
        l = []
        i += 1 S[i] == 'A' S[i] S i 'A' l.append(0) l.append l append 0 i += 1 i 1 elif S[i] == 'B' and i+1 < N and S[i+1] == 'C':
        l.append(1)
        i += 2
     S[i] == 'B' and i+1 < N and S[i+1] == 'C' S[i] == 'B' and i+1 < N S[i] == 'B' S[i] S i 'B' i+1 < N i+1 i 1 N S[i+1] == 'C' S[i+1] S i+1 i 1 'C' l.append(1) l.append l append 1 i += 2 i 2 lst.append(l) lst.append lst append l l = [] l [] i += 1 i 1 if len(l):
    lst.append(l) len(l) len l lst.append(l) lst.append lst append l ans = 0 ans 0 for l in lst:
    cnt = 0
    for x in l:
        if x == 0:
            cnt += 1
        else:
            ans += cnt l lst cnt = 0 cnt 0 for x in l:
        if x == 0:
            cnt += 1
        else:
            ans += cnt x l if x == 0:
            cnt += 1
        else:
            ans += cnt x == 0 x 0 cnt += 1 cnt 1 ans += cnt ans cnt print(ans) print ans i = 0 0 i lst = [] [] lst S = list(input()) list(input()) S i += 1 1 i N = len(S) len(S) N i += 1 1 i l = [] [] l ans += cnt cnt ans ans = 0 0 ans l = [] [] l cnt = 0 0 cnt cnt += 1 1 cnt i += 2 2 i
S = list(input())
N = len(S)
lst = []
l = []
i = 0
while i < N:
    if S[i] == 'A':
        l.append(0)
        i += 1
    elif S[i] == 'B' and i+1 < N and S[i+1] == 'C':
        l.append(1)
        i += 2
    else:
        lst.append(l)
        l = []
        i += 1
if len(l):
    lst.append(l)
ans = 0
for l in lst:
    cnt = 0
    for x in l:
        if x == 0:
            cnt += 1
        else:
            ans += cnt
print(ans)