import sys
import re
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans)


def main():
    S = input()

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == '__main__':
    main() import sys sys import re re import math math import bisect bisect import queue queue def input():
    return sys.stdin.readline().rstrip()


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans) input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    S = input()

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

    print(ans) main S = input() S input() input S = re.sub(r'(BC)', 'X', S) S re.sub(r'(BC)', 'X', S) re.sub re sub r'(BC)' 'X' S ans = 0 ans 0 cnt = 0 cnt 0 for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

     s S[::-1] S ::-1 -1 if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

     s == 'X' s 'X' cnt += 1 cnt 1 elif s == 'A':
            ans += cnt
         s == 'A' s 'A' ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def input():
    return sys.stdin.readline().rstrip()


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans) def input():
    return sys.stdin.readline().rstrip()


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans) input def main():
    S = input()

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

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

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

    print(ans) main
import sys
import re
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


# def main():
#     S = input()

#     ans = 0
#     res = re.findall(r'A*ABC(?:A|BC)*', S)
#     for r in res:
#         r = re.sub(r'(BC)', 'X', r)
#         cnt = 0
#         for c in r[::-1]:
#             if c == 'X':
#                 cnt += 1
#             else:
#                 ans += cnt

#     print(ans)


def main():
    S = input()

    S = re.sub(r'(BC)', 'X', S)

    ans = 0
    cnt = 0
    for s in S[::-1]:
        if s == 'X':
            cnt += 1
        elif s == 'A':
            ans += cnt
        else:
            cnt = 0

    print(ans)


if __name__ == '__main__':
    main()
