s = input()

ans, cnta = 0, 0
for i in range(len(s)):
    if s[i] == 'A':
        cnta += 1
    elif s[i:i + 2] == 'BC':
        ans += cnta
    elif s[i - 1:i + 1] != 'BC':
        cnta = 0
print(ans) s = input() s input() input ans, cnta = 0, 0 ans 0 cnta 0 for i in range(len(s)):
    if s[i] == 'A':
        cnta += 1
    elif s[i:i + 2] == 'BC':
        ans += cnta
    elif s[i - 1:i + 1] != 'BC':
        cnta = 0 i range(len(s)) range len(s) len s if s[i] == 'A':
        cnta += 1
    elif s[i:i + 2] == 'BC':
        ans += cnta
    elif s[i - 1:i + 1] != 'BC':
        cnta = 0 s[i] == 'A' s[i] s i 'A' cnta += 1 cnta 1 elif s[i:i + 2] == 'BC':
        ans += cnta
     s[i:i + 2] == 'BC' s[i:i + 2] s i:i + 2 i i + 2 i 2 'BC' ans += cnta ans cnta elif s[i - 1:i + 1] != 'BC':
        cnta = 0 s[i - 1:i + 1] != 'BC' s[i - 1:i + 1] s i - 1:i + 1 i - 1 i 1 i + 1 i 1 'BC' cnta = 0 cnta 0 print(ans) print ans cnta += 1 1 cnta ans, cnta = 0, 0 0 ans ans += cnta cnta ans cnta = 0, 0 0 cnta s = input() input() s cnta = 0 0 cnta
s = input()

ans, cnta = 0, 0
for i in range(len(s)):
    if s[i] == 'A':
        cnta += 1
    elif s[i:i + 2] == 'BC':
        ans += cnta
    elif s[i - 1:i + 1] != 'BC':
        cnta = 0
print(ans)
