S = input()
c = 0
i = 0
ac = 0
while i < len(S):
    if S[i] == "A":
        ac += 1
    elif S[i:i+2] == "BC":
        c += ac
        i += 1
    else:
        ac = 0
    i += 1
print(c) S = input() S input() input c = 0 c 0 i = 0 i 0 ac = 0 ac 0 while i < len(S):
    if S[i] == "A":
        ac += 1
    elif S[i:i+2] == "BC":
        c += ac
        i += 1
    else:
        ac = 0
    i += 1 i < len(S) i len(S) len S if S[i] == "A":
        ac += 1
    elif S[i:i+2] == "BC":
        c += ac
        i += 1
    else:
        ac = 0
     S[i] == "A" S[i] S i "A" ac += 1 ac 1 elif S[i:i+2] == "BC":
        c += ac
        i += 1
     S[i:i+2] == "BC" S[i:i+2] S i:i+2 i i+2 i 2 "BC" c += ac c ac i += 1 i 1 ac = 0 ac 0 i += 1 i 1 print(c) print c ac += 1 1 ac ac = 0 0 ac i += 1 1 i c += ac ac c S = input() input() S c = 0 0 c i += 1 1 i i = 0 0 i ac = 0 0 ac
S = input()
c = 0
i = 0
ac = 0
while i < len(S):
    if S[i] == "A":
        ac += 1
    elif S[i:i+2] == "BC":
        c += ac
        i += 1
    else:
        ac = 0
    i += 1
print(c)
