# https://atcoder.jp/contests/agc034/tasks/agc034_b

s = input()
s = s.replace('BC', 'X')
ans = 0
a = 0
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'X':
        ans += a
    else:
        a = 0
print(ans) s = input() s input() input s = s.replace('BC', 'X') s s.replace('BC', 'X') s.replace s replace 'BC' 'X' ans = 0 ans 0 a = 0 a 0 for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'X':
        ans += a
    else:
        a = 0 i range(len(s)) range len(s) len s if s[i] == 'A':
        a += 1
    elif s[i] == 'X':
        ans += a
    else:
        a = 0 s[i] == 'A' s[i] s i 'A' a += 1 a 1 elif s[i] == 'X':
        ans += a
     s[i] == 'X' s[i] s i 'X' ans += a ans a a = 0 a 0 print(ans) print ans ans += a a ans s = input() input() s a = 0 0 a a = 0 0 a s = s.replace('BC', 'X') s.replace('BC', 'X') s a += 1 1 a ans = 0 0 ans
# https://atcoder.jp/contests/agc034/tasks/agc034_b

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