def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    s = input()
    i = 0
    cc = output = 0
    while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
    print(output)

    return

if __name__ == '__main__':
    main() def Z(): return int(input()) Z int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ def ZZ(): return [int(_) for _ in input().split()] ZZ def main():
    s = input()
    i = 0
    cc = output = 0
    while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
    print(output)

    return main s = input() s input() input i = 0 i 0 cc = output = 0 cc 0 = output = 0 output 0 while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
     i < len(s)-1 i len(s)-1 len(s) len s 1 if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
     s[i] == 'A' s[i] s i 'A' cc += 1 cc 1 i += 1 i 1 elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
         s[i] == 'B' and s[i+1] == 'C' s[i] == 'B' s[i] s i 'B' s[i+1] == 'C' s[i+1] s i+1 i 1 'C' output += cc output cc i += 2 i 2 cc = 0 cc 0 i += 1 i 1 print(output) print output return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def ZZ(): return [int(_) for _ in input().split()] def ZZ(): return [int(_) for _ in input().split()] ZZ def Z(): return int(input()) def Z(): return int(input()) Z def main():
    s = input()
    i = 0
    cc = output = 0
    while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
    print(output)

    return def main():
    s = input()
    i = 0
    cc = output = 0
    while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
    print(output)

    return main
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    s = input()
    i = 0
    cc = output = 0
    while i < len(s)-1:
        if s[i] == 'A':
            cc += 1
            i += 1
        elif s[i] == 'B' and s[i+1] == 'C':
            output += cc
            i += 2
        else:
            cc = 0
            i += 1
    print(output)

    return

if __name__ == '__main__':
    main()
