S = input()
S = S.replace("BC", "X")
n = len(S)
ans = 0
cnt_a = 0

for s in S:
    if s == "X":
        ans += cnt_a
    elif s == "A":
        cnt_a += 1
    else:
        cnt_a = 0

print(ans) S = input() S input() input S = S.replace("BC", "X") S S.replace("BC", "X") S.replace S replace "BC" "X" n = len(S) n len(S) len S ans = 0 ans 0 cnt_a = 0 cnt_a 0 for s in S:
    if s == "X":
        ans += cnt_a
    elif s == "A":
        cnt_a += 1
    else:
        cnt_a = 0 s S if s == "X":
        ans += cnt_a
    elif s == "A":
        cnt_a += 1
    else:
        cnt_a = 0 s == "X" s "X" ans += cnt_a ans cnt_a elif s == "A":
        cnt_a += 1
     s == "A" s "A" cnt_a += 1 cnt_a 1 cnt_a = 0 cnt_a 0 print(ans) print ans ans += cnt_a cnt_a ans cnt_a = 0 0 cnt_a S = input() input() S S = S.replace("BC", "X") S.replace("BC", "X") S cnt_a += 1 1 cnt_a n = len(S) len(S) n cnt_a = 0 0 cnt_a ans = 0 0 ans
S = input()
S = S.replace("BC", "X")
n = len(S)
ans = 0
cnt_a = 0

for s in S:
    if s == "X":
        ans += cnt_a
    elif s == "A":
        cnt_a += 1
    else:
        cnt_a = 0

print(ans)
