from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



s = eval(input())

n = len(s)

res = 0

bc = 0

i = n-1

while i >= 0:

    if s[i] == 'A':

        res += bc

        i -= 1

    elif i != 0 and s[i-1] == 'B' and s[i] == 'C':

        bc += 1

        i -= 2

    else:

        bc = 0

        i -= 1

print(res)
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



s = eval(input())

n = len(s)

ind = n-1

cnt = 0

res = 0

f = False

while ind >= 0:

    if ind-1 >= 0 and (s[ind-1],s[ind]) == ('B','C'):

        f = True

        cnt += 1

        ind -= 2

    elif f and s[ind] == 'A':

        res += cnt

        ind -= 1

    else:

        f = False

        cnt = 0

        ind -= 1

print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


s = eval(input())
n = len(s)
res = 0
bc = 0
i = n - 1
while i >= 0:
    if s[i] == "A":
        res += bc
        i -= 1
    elif i != 0 and s[i - 1] == "B" and s[i] == "C":
        bc += 1
        i -= 2
    else:
        bc = 0
        i -= 1
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


s = eval(input())
n = len(s)
ind = n - 1
cnt = 0
res = 0
f = False
while ind >= 0:
    if ind - 1 >= 0 and (s[ind - 1], s[ind]) == ("B", "C"):
        f = True
        cnt += 1
        ind -= 2
    elif f and s[ind] == "A":
        res += cnt
        ind -= 1
    else:
        f = False
        cnt = 0
        ind -= 1
print(res)

-import sys, bisect, math, itertools, fractions, pprint +import sys, bisect, math, itertools, fractions -def inpln(n): -    return list(int(sys.stdin.readline()) for i in range(n)) - - +ind = n - 1 +cnt = 0 -bc = 0 -i = n - 1 -while i >= 0: -    if s[i] == "A": -        res += bc -        i -= 1 -    elif i != 0 and s[i - 1] == "B" and s[i] == "C": -        bc += 1 -        i -= 2 +f = False +while ind >= 0: +    if ind - 1 >= 0 and (s[ind - 1], s[ind]) == ("B", "C"): +        f = True +        cnt += 1 +        ind -= 2 +    elif f and s[ind] == "A": +        res += cnt +        ind -= 1 -        bc = 0 -        i -= 1 +        f = False +        cnt = 0 +        ind -= 1