s = input()
s = s.replace('BC', '1')
ans = 0
a = 0
for s_ in s:
    if s_ == 'A':
        a += 1
    elif s_ == '1':
        ans += a
    else:
        a = 0
print(ans) s = input() s input() input s = s.replace('BC', '1') s s.replace('BC', '1') s.replace s replace 'BC' '1' ans = 0 ans 0 a = 0 a 0 for s_ in s:
    if s_ == 'A':
        a += 1
    elif s_ == '1':
        ans += a
    else:
        a = 0 s_ s if s_ == 'A':
        a += 1
    elif s_ == '1':
        ans += a
    else:
        a = 0 s_ == 'A' s_ 'A' a += 1 a 1 elif s_ == '1':
        ans += a
     s_ == '1' s_ '1' ans += a ans a a = 0 a 0 print(ans) print ans s = input() input() s s = s.replace('BC', '1') s.replace('BC', '1') s a += 1 1 a ans += a a ans ans = 0 0 ans a = 0 0 a a = 0 0 a
s = input()
s = s.replace('BC', '1')
ans = 0
a = 0
for s_ in s:
    if s_ == 'A':
        a += 1
    elif s_ == '1':
        ans += a
    else:
        a = 0
print(ans)
