import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    t = s.replace("BC", "X")

    ans = 0
    cnt = 0

    for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    s = input()
    t = s.replace("BC", "X")

    ans = 0
    cnt = 0

    for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

    print(ans) main s = input() s input() input t = s.replace("BC", "X") t s.replace("BC", "X") s.replace s replace "BC" "X" ans = 0 ans 0 cnt = 0 cnt 0 for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

     char t[::-1] t ::-1 -1 if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

     char == "X" char "X" cnt += 1 cnt 1 elif char == "A":
            ans += cnt
         char == "A" char "A" ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    s = input()
    t = s.replace("BC", "X")

    ans = 0
    cnt = 0

    for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

    print(ans) def main():
    s = input()
    t = s.replace("BC", "X")

    ans = 0
    cnt = 0

    for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

    print(ans) main readline = sys.stdin.readline sys.stdin.readline readline INF = float('INF') float('INF') INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    t = s.replace("BC", "X")

    ans = 0
    cnt = 0

    for char in t[::-1]:
        if char == "X":
            cnt += 1
        elif char == "A":
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == '__main__':
    main()
