import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    lS = list(S)
    acnt = 0
    ans = 0
    for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

    print(ans)



if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    S = input().strip()

    lS = list(S)
    acnt = 0
    ans = 0
    for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

    print(ans) main S = input().strip() S input().strip() ().strip () input strip lS = list(S) lS list(S) list S acnt = 0 acnt 0 ans = 0 ans 0 for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

     i range(len(S) - 2) range len(S) - 2 len(S) len S 2 if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

         lS[i] == "A" lS[i] lS i "A" acnt += 1 acnt 1 acnt = 0 acnt 0 if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

     lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C" lS[i] == "A" and lS[i + 1] == "B" lS[i] == "A" lS[i] lS i "A" lS[i + 1] == "B" lS[i + 1] lS i + 1 i 1 "B" lS[i + 2] == "C" lS[i + 2] lS i + 2 i 2 "C" ans += acnt ans acnt lS[i + 2] = "A" lS[i + 2] lS i + 2 i 2 "A" if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

     acnt > 1 acnt 1 lS[i + 1] = "A" lS[i + 1] lS i + 1 i 1 "A" acnt -= 2 acnt 2 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    S = input().strip()

    lS = list(S)
    acnt = 0
    ans = 0
    for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

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

    lS = list(S)
    acnt = 0
    ans = 0
    for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    lS = list(S)
    acnt = 0
    ans = 0
    for i in range(len(S) - 2):
        if lS[i] == "A":
            acnt += 1
        else:
            acnt = 0

        if lS[i] == "A" and lS[i + 1] == "B" and lS[i + 2] == "C":
            ans += acnt
            lS[i + 2] = "A"
            if acnt > 1:
                lS[i + 1] = "A"
                acnt -= 2

    print(ans)



if __name__ == '__main__':
    main()
