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