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

ans, cnt = 0, 0
for s in news:
    if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0

print(ans) S = input() S input() input news = S.replace('BC', 'D') news S.replace('BC', 'D') S.replace S replace 'BC' 'D' ans, cnt = 0, 0 ans 0 cnt 0 for s in news:
    if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0 s news if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0 s == 'A' s 'A' cnt += 1 cnt 1 elif s == 'D':
        ans += cnt
     s == 'D' s 'D' ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans cnt = 0, 0 0 cnt S = input() input() S ans += cnt cnt ans cnt += 1 1 cnt cnt = 0 0 cnt news = S.replace('BC', 'D') S.replace('BC', 'D') news ans, cnt = 0, 0 0 ans
S = input()
news = S.replace('BC', 'D')

ans, cnt = 0, 0
for s in news:
    if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0

print(ans)