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

cnt_a = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'A':
        cnt_a += 1
    elif S[i] == 'D':
        ans += cnt_a
    else:
        cnt_a = 0

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

cnt_a = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'A':
        cnt_a += 1
    elif S[i] == 'D':
        ans += cnt_a
    else:
        cnt_a = 0

print(ans)
