import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input().replace("BC", "D")

    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    S = input().replace("BC", "D")

    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res) resolve S = input().replace("BC", "D") S input().replace("BC", "D") ().replace () input replace "BC" "D" res = 0 res 0 cnt = 0 cnt 0 for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
     s S if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
     s == "A" s "A" cnt += 1 cnt 1 elif s == "D":
            res += cnt
         s == "D" s "D" res += cnt res cnt cnt = 0 cnt 0 print(res) print res if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def resolve():
    S = input().replace("BC", "D")

    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res) def resolve():
    S = input().replace("BC", "D")

    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res) resolve f_inf = float('inf') float('inf') f_inf mod = 10 ** 9 + 7 10 ** 9 + 7 mod
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input().replace("BC", "D")

    res = 0
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
        elif s == "D":
            res += cnt
        else:
            cnt = 0
    print(res)


if __name__ == '__main__':
    resolve()
