S = input()
S = S.replace('BC', '>')

ans = 0
a_count = 0
for s in S:
    if s == 'A':
        a_count += 1

    elif s == '>':
        ans += a_count

    else:
        a_count = 0

print(ans) S = input() S input() input S = S.replace('BC', '>') S S.replace('BC', '>') S.replace S replace 'BC' '>' ans = 0 ans 0 a_count = 0 a_count 0 for s in S:
    if s == 'A':
        a_count += 1

    elif s == '>':
        ans += a_count

    else:
        a_count = 0 s S if s == 'A':
        a_count += 1

    elif s == '>':
        ans += a_count

    else:
        a_count = 0 s == 'A' s 'A' a_count += 1 a_count 1 elif s == '>':
        ans += a_count

     s == '>' s '>' ans += a_count ans a_count a_count = 0 a_count 0 print(ans) print ans S = S.replace('BC', '>') S.replace('BC', '>') S S = input() input() S ans = 0 0 ans ans += a_count a_count ans a_count = 0 0 a_count a_count += 1 1 a_count a_count = 0 0 a_count
S = input()
S = S.replace('BC', '>')

ans = 0
a_count = 0
for s in S:
    if s == 'A':
        a_count += 1

    elif s == '>':
        ans += a_count

    else:
        a_count = 0

print(ans)
