import re


def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer)


if __name__ == '__main__':
    main() import re re def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer) main s = input().replace('BC', 'X') s input().replace('BC', 'X') ().replace () input replace 'BC' 'X' S = re.split('[BC]', s) S re.split('[BC]', s) re.split re split '[BC]' s answer = 0 answer 0 for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

     i S tmp = 0 tmp 0 for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

     j i if j == 'A':
                tmp += 1
            else:
                answer += tmp

     j == 'A' j 'A' tmp += 1 tmp 1 answer += tmp answer tmp print(answer) print answer if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer) def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer) main
import re


def main():
    s = input().replace('BC', 'X')
    S = re.split('[BC]', s)
    answer = 0

    for i in S:
        tmp = 0
        for j in i:
            if j == 'A':
                tmp += 1
            else:
                answer += tmp

    print(answer)


if __name__ == '__main__':
    main()