def main():
    ans = 0
    S = input()
    N = len(S)
    ans = 0
    now = 0
    skip = -1
    for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
    print(ans)


if __name__ == '__main__':
    main() def main():
    ans = 0
    S = input()
    N = len(S)
    ans = 0
    now = 0
    skip = -1
    for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
    print(ans) main ans = 0 ans 0 S = input() S input() input N = len(S) N len(S) len S ans = 0 ans 0 now = 0 now 0 skip = -1 skip -1 for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
     i s enumerate(S) enumerate S if i <= skip:
            continue
         i <= skip i skip continue if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
     s == "A" and S[i+1:i+3] == "BC" s == "A" s "A" S[i+1:i+3] == "BC" S[i+1:i+3] S i+1:i+3 i+1 i 1 i+3 i 3 "BC" now += 1 now 1 ans += now ans now skip = i+2 skip i+2 i 2 elif s == "A":
            now += 1
         s == "A" s "A" now += 1 now 1 elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
         s == "B" and i < N-1 and S[i+1] == "C" s == "B" and i < N-1 s == "B" s "B" i < N-1 i N-1 N 1 S[i+1] == "C" S[i+1] S i+1 i 1 "C" ans += now ans now skip = i+1 skip i+1 i 1 now = 0 now 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    ans = 0
    S = input()
    N = len(S)
    ans = 0
    now = 0
    skip = -1
    for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
    print(ans) def main():
    ans = 0
    S = input()
    N = len(S)
    ans = 0
    now = 0
    skip = -1
    for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
    print(ans) main
def main():
    ans = 0
    S = input()
    N = len(S)
    ans = 0
    now = 0
    skip = -1
    for i, s in enumerate(S):
        if i <= skip:
            continue
        if s == "A" and S[i+1:i+3] == "BC":
            now += 1
            ans += now
            skip = i+2
        elif s == "A":
            now += 1
        elif s == "B" and i < N-1 and S[i+1] == "C":
            ans += now
            skip = i+1
        else:
            now = 0
    print(ans)


if __name__ == '__main__':
    main()
