# -*- coding: utf-8 -*-

s = eval(input())



a_num = 0

ans = 0

i = 0

while i < len(s):

    if s[i] == 'A':

        a_num += 1

        i += 1

    elif s[i:i+2] == 'BC':

        ans += a_num

        i += 2

    else:

        a_num = 0

        i += 1



print(ans)

# -*- coding: utf-8 -*-

s = eval(input())

s = s.replace('BC', 'D')



a_num = 0

ans = 0

for c in s:

    if c == 'A':

        a_num += 1

    elif c == 'D':

        ans += a_num

    else:

        a_num = 0



print(ans)

# -*- coding: utf-8 -*-
s = eval(input())
a_num = 0
ans = 0
i = 0
while i < len(s):
    if s[i] == "A":
        a_num += 1
        i += 1
    elif s[i : i + 2] == "BC":
        ans += a_num
        i += 2
    else:
        a_num = 0
        i += 1
print(ans)

# -*- coding: utf-8 -*-
s = eval(input())
s = s.replace("BC", "D")
a_num = 0
ans = 0
for c in s:
    if c == "A":
        a_num += 1
    elif c == "D":
        ans += a_num
    else:
        a_num = 0
print(ans)

+s = s.replace("BC", "D") -i = 0 -while i < len(s): -    if s[i] == "A": +for c in s: +    if c == "A": -        i += 1 -    elif s[i : i + 2] == "BC": +    elif c == "D": -        i += 2 -        i += 1