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

ret = 0
a_frq = 0
for s in S:
    if s == 'A':
        a_frq += 1

    elif s == 'X':
        ret += a_frq

    else:
        a_frq = 0

print(ret) S = input() S input() input S = S.replace('BC', 'X') S S.replace('BC', 'X') S.replace S replace 'BC' 'X' ret = 0 ret 0 a_frq = 0 a_frq 0 for s in S:
    if s == 'A':
        a_frq += 1

    elif s == 'X':
        ret += a_frq

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

    elif s == 'X':
        ret += a_frq

    else:
        a_frq = 0 s == 'A' s 'A' a_frq += 1 a_frq 1 elif s == 'X':
        ret += a_frq

     s == 'X' s 'X' ret += a_frq ret a_frq a_frq = 0 a_frq 0 print(ret) print ret a_frq = 0 0 a_frq a_frq += 1 1 a_frq ret = 0 0 ret S = input() input() S S = S.replace('BC', 'X') S.replace('BC', 'X') S a_frq = 0 0 a_frq ret += a_frq a_frq ret
S = input()
S = S.replace('BC', 'X')

ret = 0
a_frq = 0
for s in S:
    if s == 'A':
        a_frq += 1

    elif s == 'X':
        ret += a_frq

    else:
        a_frq = 0

print(ret)
