def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans)


if __name__ == '__main__':
    main() def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 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" N = len(S) N len(S) len S ans = 0 ans 0 a_cnt = 0 a_cnt 0 for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
     i range(N) range N if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
     S[i] == "A" S[i] S i "A" a_cnt += 1 a_cnt 1 elif S[i] == "D":
            ans += a_cnt
         S[i] == "D" S[i] S i "D" ans += a_cnt ans a_cnt a_cnt = 0 a_cnt 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans) def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans) main
def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans)


if __name__ == '__main__':
    main()
