import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = [c for c in gete()]
    ans = 0
    a = 0
    cur = 0
    while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

    print(ans)


if __name__ == "__main__":
    main() import sys sys from collections import defaultdict readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) geta return map(fn, readline().split()) map(fn, readline().split()) map fn readline().split() ().split () readline split fn=lambda s: s.decode() fn lambda s: s.decode() s.decode() s.decode s decode s def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) gete return fn(readline().rstrip()) fn(readline().rstrip()) fn readline().rstrip() ().rstrip () readline rstrip fn=lambda s: s.decode() fn lambda s: s.decode() s.decode() s.decode s decode s def main():
    s = [c for c in gete()]
    ans = 0
    a = 0
    cur = 0
    while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

    print(ans) main c for c in gete() for c in gete() c gete() gete for c in gete() c s = [c for c in gete()] s [c for c in gete()] ans = 0 ans 0 a = 0 a 0 cur = 0 cur 0 while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

     cur < len(s) - 2 cur len(s) - 2 len(s) len s 2 if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

     "".join(s[cur:cur + 3]) == "ABC" "".join(s[cur:cur + 3]) "".join "" join s[cur:cur + 3] s cur:cur + 3 cur cur + 3 cur 3 "ABC" ans += a + 1 ans a + 1 a 1 cur += 2 cur 2 s[cur] = "A" s[cur] s cur "A" if s[cur] == "A":
                a += 1
            else:
                a = 0
             s[cur] == "A" s[cur] s cur "A" a += 1 a 1 a = 0 a 0 cur += 1 cur 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s = [c for c in gete()]
    ans = 0
    a = 0
    cur = 0
    while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

    print(ans) def main():
    s = [c for c in gete()]
    ans = 0
    a = 0
    cur = 0
    while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

    print(ans) main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) geta def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) gete
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = [c for c in gete()]
    ans = 0
    a = 0
    cur = 0
    while cur < len(s) - 2:

        if "".join(s[cur:cur + 3]) == "ABC":
            ans += a + 1
            cur += 2
            s[cur] = "A"
        else:
            if s[cur] == "A":
                a += 1
            else:
                a = 0
            cur += 1

    print(ans)


if __name__ == "__main__":
    main()