S = list(input().replace("BC", "X"))
N = len(S)
pos, ans = 0, 0
ca = 0

while pos<N:
    ca = 0
    if S[pos]=="A" or S[pos]=="X":
        while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
    else:
        pos += 1

print(ans) S = list(input().replace("BC", "X")) S list(input().replace("BC", "X")) list input().replace("BC", "X") ().replace () input replace "BC" "X" N = len(S) N len(S) len S pos, ans = 0, 0 pos 0 ans 0 ca = 0 ca 0 while pos<N:
    ca = 0
    if S[pos]=="A" or S[pos]=="X":
        while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
    else:
        pos += 1 pos<N pos N ca = 0 ca 0 if S[pos]=="A" or S[pos]=="X":
        while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
    else:
        pos += 1 S[pos]=="A" or S[pos]=="X" S[pos]=="A" S[pos] S pos "A" S[pos]=="X" S[pos] S pos "X" while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
     pos<N and (S[pos]=="A" or S[pos]=="X") pos<N pos N S[pos]=="A" or S[pos]=="X" S[pos]=="A" S[pos] S pos "A" S[pos]=="X" S[pos] S pos "X" if S[pos]=="A":
                ca += 1
            else:
                ans += ca
             S[pos]=="A" S[pos] S pos "A" ca += 1 ca 1 ans += ca ans ca pos += 1 pos 1 pos += 1 pos 1 print(ans) print ans pos += 1 1 pos S = list(input().replace("BC", "X")) list(input().replace("BC", "X")) S pos, ans = 0, 0 0 pos pos += 1 1 pos ans += ca ca ans ans = 0, 0 0 ans ca = 0 0 ca ca += 1 1 ca N = len(S) len(S) N ca = 0 0 ca
S = list(input().replace("BC", "X"))
N = len(S)
pos, ans = 0, 0
ca = 0

while pos<N:
    ca = 0
    if S[pos]=="A" or S[pos]=="X":
        while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
    else:
        pos += 1

print(ans)