import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


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


if __name__ == "__main__":
    main() import sys sys def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 def main():
    S = input()
    S = S.replace("BC", "X")
    cnt_a = 0
    answer = 0
    for s in S:
        if s == "A":
            cnt_a += 1
        elif s == "X":
            answer += cnt_a
        else:
            cnt_a = 0
    print(answer) main S = input() S input() input S = S.replace("BC", "X") S S.replace("BC", "X") S.replace S replace "BC" "X" cnt_a = 0 cnt_a 0 answer = 0 answer 0 for s in S:
        if s == "A":
            cnt_a += 1
        elif s == "X":
            answer += cnt_a
        else:
            cnt_a = 0
     s S if s == "A":
            cnt_a += 1
        elif s == "X":
            answer += cnt_a
        else:
            cnt_a = 0
     s == "A" s "A" cnt_a += 1 cnt_a 1 elif s == "X":
            answer += cnt_a
         s == "X" s "X" answer += cnt_a answer cnt_a cnt_a = 0 cnt_a 0 print(answer) print answer if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    S = input()
    S = S.replace("BC", "X")
    cnt_a = 0
    answer = 0
    for s in S:
        if s == "A":
            cnt_a += 1
        elif s == "X":
            answer += cnt_a
        else:
            cnt_a = 0
    print(answer) def main():
    S = input()
    S = S.replace("BC", "X")
    cnt_a = 0
    answer = 0
    for s in S:
        if s == "A":
            cnt_a += 1
        elif s == "X":
            answer += cnt_a
        else:
            cnt_a = 0
    print(answer) main def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


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


if __name__ == "__main__":
    main()
