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

cnt = 0
ans = 0
for i, s in enumerate(S):
    if s == 'D':
        ans += cnt
    elif s == 'A':
        cnt += 1
    else:
        cnt = 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 = 0 cnt 0 ans = 0 ans 0 for i, s in enumerate(S):
    if s == 'D':
        ans += cnt
    elif s == 'A':
        cnt += 1
    else:
        cnt = 0 i s enumerate(S) enumerate S if s == 'D':
        ans += cnt
    elif s == 'A':
        cnt += 1
    else:
        cnt = 0 s == 'D' s 'D' ans += cnt ans cnt elif s == 'A':
        cnt += 1
     s == 'A' s 'A' cnt += 1 cnt 1 cnt = 0 cnt 0 print(ans) print ans cnt = 0 0 cnt cnt += 1 1 cnt cnt = 0 0 cnt ans += cnt cnt ans S = input() input() S ans = 0 0 ans S = S.replace('BC', 'D') S.replace('BC', 'D') S
S = input()
S = S.replace('BC', 'D')

cnt = 0
ans = 0
for i, s in enumerate(S):
    if s == 'D':
        ans += cnt
    elif s == 'A':
        cnt += 1
    else:
        cnt = 0
print(ans)
