s = str(input())
ans = 0
i = 0
cnt = 0
while i < len(s) - 1:
    if s[i] == 'A':
        cnt += 1
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
    else:
        cnt = 0
        i += 1
print(ans) s = str(input()) s str(input()) str input() input ans = 0 ans 0 i = 0 i 0 cnt = 0 cnt 0 while i < len(s) - 1:
    if s[i] == 'A':
        cnt += 1
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
    else:
        cnt = 0
        i += 1 i < len(s) - 1 i len(s) - 1 len(s) len s 1 if s[i] == 'A':
        cnt += 1
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
    else:
        cnt = 0
        i += 1 s[i] == 'A' s[i] s i 'A' cnt += 1 cnt 1 i += 1 i 1 elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
     s[i] == 'B' s[i] s i 'B' if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
     s[i+1] == 'C' s[i+1] s i+1 i 1 'C' ans += cnt ans cnt i += 2 i 2 cnt = 0 cnt 0 i += 1 i 1 cnt = 0 cnt 0 i += 1 i 1 print(ans) print ans cnt = 0 0 cnt i += 1 1 i ans += cnt cnt ans i += 1 1 i cnt = 0 0 cnt cnt = 0 0 cnt i = 0 0 i ans = 0 0 ans s = str(input()) str(input()) s cnt += 1 1 cnt i += 1 1 i i += 2 2 i
s = str(input())
ans = 0
i = 0
cnt = 0
while i < len(s) - 1:
    if s[i] == 'A':
        cnt += 1
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
    else:
        cnt = 0
        i += 1
print(ans)
