import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()

s = s.replace("BC", "D")

cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        cnt += 1
    elif s[i] == 'D':
        ans += cnt
    else:
        cnt = 0

print(ans) import sys sys stdin = sys.stdin stdin sys.stdin sys stdin inf = 1 << 60 inf 1 << 60 1 60 mod = 1000000007 mod 1000000007 sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 ni = lambda: int(ns()) ni lambda: int(ns()) int(ns()) int ns() ns ni() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) ni() ni nin = lambda y: [ni() for _ in range(y)] nin lambda y: [ni() for _ in range(y)] [ni() for _ in range(y)] y na = lambda: list(map(int, stdin.readline().split())) na lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split na() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) na() na nan = lambda y: [na() for _ in range(y)] nan lambda y: [na() for _ in range(y)] [na() for _ in range(y)] y nf = lambda: float(ns()) nf lambda: float(ns()) float(ns()) float ns() ns nf() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) nf() nf nfn = lambda y: [nf() for _ in range(y)] nfn lambda y: [nf() for _ in range(y)] [nf() for _ in range(y)] y nfa = lambda: list(map(float, stdin.readline().split())) nfa lambda: list(map(float, stdin.readline().split())) list(map(float, stdin.readline().split())) list map(float, stdin.readline().split()) map float stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split nfa() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) nfa() nfa nfan = lambda y: [nfa() for _ in range(y)] nfan lambda y: [nfa() for _ in range(y)] [nfa() for _ in range(y)] y ns = lambda: stdin.readline().rstrip() ns lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip ns() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) ns() ns nsn = lambda y: [ns() for _ in range(y)] nsn lambda y: [ns() for _ in range(y)] [ns() for _ in range(y)] y list(ns()) for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) list(ns()) list ns() ns ncl = lambda y: [list(ns()) for _ in range(y)] ncl lambda y: [list(ns()) for _ in range(y)] [list(ns()) for _ in range(y)] y nas = lambda: stdin.readline().split() nas lambda: stdin.readline().split() stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split s = ns() s ns() ns s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" cnt = 0 cnt 0 ans = 0 ans 0 for i in range(len(s)):
    if s[i] == 'A':
        cnt += 1
    elif s[i] == 'D':
        ans += cnt
    else:
        cnt = 0 i range(len(s)) range len(s) len s if s[i] == 'A':
        cnt += 1
    elif s[i] == 'D':
        ans += cnt
    else:
        cnt = 0 s[i] == 'A' s[i] s i 'A' cnt += 1 cnt 1 elif s[i] == 'D':
        ans += cnt
     s[i] == 'D' s[i] s i 'D' ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans ans += cnt cnt ans nfa = lambda: list(map(float, stdin.readline().split())) lambda: list(map(float, stdin.readline().split())) nfa s = s.replace("BC", "D") s.replace("BC", "D") s nfan = lambda y: [nfa() for _ in range(y)] lambda y: [nfa() for _ in range(y)] nfan nsn = lambda y: [ns() for _ in range(y)] lambda y: [ns() for _ in range(y)] nsn s = ns() ns() s mod = 1000000007 1000000007 mod nfn = lambda y: [nf() for _ in range(y)] lambda y: [nf() for _ in range(y)] nfn nin = lambda y: [ni() for _ in range(y)] lambda y: [ni() for _ in range(y)] nin na = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) na cnt = 0 0 cnt nan = lambda y: [na() for _ in range(y)] lambda y: [na() for _ in range(y)] nan cnt += 1 1 cnt ncl = lambda y: [list(ns()) for _ in range(y)] lambda y: [list(ns()) for _ in range(y)] ncl ns = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() ns ans = 0 0 ans ni = lambda: int(ns()) lambda: int(ns()) ni stdin = sys.stdin sys.stdin stdin nas = lambda: stdin.readline().split() lambda: stdin.readline().split() nas nf = lambda: float(ns()) lambda: float(ns()) nf inf = 1 << 60 1 << 60 inf cnt = 0 0 cnt
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()

s = s.replace("BC", "D")

cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        cnt += 1
    elif s[i] == 'D':
        ans += cnt
    else:
        cnt = 0

print(ans)