s = input()

S = []
N = len(s)
i = 0
while i < N:
    if i < N - 1 and s[i:i + 2] == 'BC':
        S.append('D')
        i += 2
    else:
        S.append(s[i])
        i += 1

ans = 0
c = 0
for l in S:
    if l == 'A':
        c += 1
    elif l == 'D':
        ans += c
    else:
        c = 0
print(ans) s = input() s input() input S = [] S [] N = len(s) N len(s) len s i = 0 i 0 while i < N:
    if i < N - 1 and s[i:i + 2] == 'BC':
        S.append('D')
        i += 2
    else:
        S.append(s[i])
        i += 1 i < N i N if i < N - 1 and s[i:i + 2] == 'BC':
        S.append('D')
        i += 2
    else:
        S.append(s[i])
        i += 1 i < N - 1 and s[i:i + 2] == 'BC' i < N - 1 i N - 1 N 1 s[i:i + 2] == 'BC' s[i:i + 2] s i:i + 2 i i + 2 i 2 'BC' S.append('D') S.append S append 'D' i += 2 i 2 S.append(s[i]) S.append S append s[i] s i i += 1 i 1 ans = 0 ans 0 c = 0 c 0 for l in S:
    if l == 'A':
        c += 1
    elif l == 'D':
        ans += c
    else:
        c = 0 l S if l == 'A':
        c += 1
    elif l == 'D':
        ans += c
    else:
        c = 0 l == 'A' l 'A' c += 1 c 1 elif l == 'D':
        ans += c
     l == 'D' l 'D' ans += c ans c c = 0 c 0 print(ans) print ans s = input() input() s c = 0 0 c i = 0 0 i c = 0 0 c N = len(s) len(s) N ans = 0 0 ans S = [] [] S c += 1 1 c i += 2 2 i ans += c c ans i += 1 1 i
s = input()

S = []
N = len(s)
i = 0
while i < N:
    if i < N - 1 and s[i:i + 2] == 'BC':
        S.append('D')
        i += 2
    else:
        S.append(s[i])
        i += 1

ans = 0
c = 0
for l in S:
    if l == 'A':
        c += 1
    elif l == 'D':
        ans += c
    else:
        c = 0
print(ans)
