import re
s = input()
sub = re.sub('BC', 'X', s)

ans = 0
a = 0
for i in range(len(sub)):
    if sub[i] == 'A':
        a += 1
    elif sub[i] == 'X':
        ans += a
    else:
        a = 0

print(ans) import re re s = input() s input() input sub = re.sub('BC', 'X', s) sub re.sub('BC', 'X', s) re.sub re sub 'BC' 'X' s ans = 0 ans 0 a = 0 a 0 for i in range(len(sub)):
    if sub[i] == 'A':
        a += 1
    elif sub[i] == 'X':
        ans += a
    else:
        a = 0 i range(len(sub)) range len(sub) len sub if sub[i] == 'A':
        a += 1
    elif sub[i] == 'X':
        ans += a
    else:
        a = 0 sub[i] == 'A' sub[i] sub i 'A' a += 1 a 1 elif sub[i] == 'X':
        ans += a
     sub[i] == 'X' sub[i] sub i 'X' ans += a ans a a = 0 a 0 print(ans) print ans ans += a a ans ans = 0 0 ans a = 0 0 a sub = re.sub('BC', 'X', s) re.sub('BC', 'X', s) sub a += 1 1 a s = input() input() s a = 0 0 a
import re
s = input()
sub = re.sub('BC', 'X', s)

ans = 0
a = 0
for i in range(len(sub)):
    if sub[i] == 'A':
        a += 1
    elif sub[i] == 'X':
        ans += a
    else:
        a = 0

print(ans)