def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans)

if __name__ == "__main__":
    main() def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans) main S = input() S input() input S = S.replace("BC", "D") S S.replace("BC", "D") S.replace S replace "BC" "D" ans = 0 ans 0 count_A = 0 count_A 0 for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
     c S if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
     c == "A" c "A" count_A += 1 count_A 1 elif c == "D":
            ans += count_A
         c == "D" c "D" ans += count_A ans count_A count_A = 0 count_A 0 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans) def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans) main
def main():
    S = input()
    S = S.replace("BC", "D")

    ans = 0
    count_A = 0
    for c in S:
        if c == "A":
            count_A += 1
        elif c == "D":
            ans += count_A
        else:
            count_A = 0
    print(ans)

if __name__ == "__main__":
    main()