S = input()
N = len(S)
a = 0
ans = 0
f = 0
for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0
print(ans) S = input() S input() input N = len(S) N len(S) len S a = 0 a 0 ans = 0 ans 0 f = 0 f 0 for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0 i range(N-1) range N-1 N 1 if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0 S[i] == 'A' S[i] S i 'A' a += 1 a 1 elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
     S[i] == 'B' S[i] S i 'B' if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
     S[i+1] == 'C' S[i+1] S i+1 i 1 'C' ans += a ans a f = 1 f 1 a = 0 a 0 if f != 1:
            a = 0
        else:
            f = 0 f != 1 f 1 a = 0 a 0 f = 0 f 0 print(ans) print ans f = 0 0 f f = 0 0 f a += 1 1 a S = input() input() S ans += a a ans ans = 0 0 ans f = 1 1 f a = 0 0 a a = 0 0 a N = len(S) len(S) N a = 0 0 a
S = input()
N = len(S)
a = 0
ans = 0
f = 0
for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0
print(ans)