
def resolve():
    S = input()

    rep_S = S.replace("BC", "D")
    cnt = 0
    ans = 0
    for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == "__main__":
    resolve() def resolve():
    S = input()

    rep_S = S.replace("BC", "D")
    cnt = 0
    ans = 0
    for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

    print(ans) resolve S = input() S input() input rep_S = S.replace("BC", "D") rep_S S.replace("BC", "D") S.replace S replace "BC" "D" cnt = 0 cnt 0 ans = 0 ans 0 for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

     i range(len(rep_S)) range len(rep_S) len rep_S if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

     rep_S[i] == "A" rep_S[i] rep_S i "A" cnt += 1 cnt 1 elif rep_S[i] == "D":
            ans += cnt
         rep_S[i] == "D" rep_S[i] rep_S i "D" ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    S = input()

    rep_S = S.replace("BC", "D")
    cnt = 0
    ans = 0
    for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

    print(ans) def resolve():
    S = input()

    rep_S = S.replace("BC", "D")
    cnt = 0
    ans = 0
    for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

    print(ans) resolve

def resolve():
    S = input()

    rep_S = S.replace("BC", "D")
    cnt = 0
    ans = 0
    for i in range(len(rep_S)):
        if rep_S[i] == "A":
            cnt += 1
        elif rep_S[i] == "D":
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == "__main__":
    resolve()