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

cnt = 0
ans = 0
for s in S[::-1]:
    if s == 'X':
        cnt += 1
    elif s == 'A':
        ans += cnt
    else:
        cnt = 0

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

cnt = 0
ans = 0
for s in S[::-1]:
    if s == 'X':
        cnt += 1
    elif s == 'A':
        ans += cnt
    else:
        cnt = 0

print(ans)