#AGC034-B ABC
"""
ABC→BCA
ABCBC→BCABC→BCBCA
AABC→ABCA→BCAA

"BC"の文字列は絶対に不変で、これが"A"を左から右にキャリーする役割を持つ。
それ以外の文字列、Bの後にCが無い状態もしくは、Cの前にBが無い時、キャリーが終わる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
ans = 0 
a_ct = 0
bc_ct = 0
flag = 0
for i in range(len(s)-1):
    if flag:
        flag = 0
        continue
    if s[i] == "A":
        a_ct += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
    else:
        a_ct = 0
        bc_ct = 0

print(ans) """
ABC→BCA
ABCBC→BCABC→BCBCA
AABC→ABCA→BCAA

"BC"の文字列は絶対に不変で、これが"A"を左から右にキャリーする役割を持つ。
それ以外の文字列、Bの後にCが無い状態もしくは、Cの前にBが無い時、キャリーが終わる。
""" import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def even(n): return 1 if n%2==0 else 0 even n n s = readline().rstrip().decode('utf-8') s readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' ans = 0 ans 0 a_ct = 0 a_ct 0 bc_ct = 0 bc_ct 0 flag = 0 flag 0 for i in range(len(s)-1):
    if flag:
        flag = 0
        continue
    if s[i] == "A":
        a_ct += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
    else:
        a_ct = 0
        bc_ct = 0 i range(len(s)-1) range len(s)-1 len(s) len s 1 if flag:
        flag = 0
        continue
     flag flag = 0 flag 0 continue if s[i] == "A":
        a_ct += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
    else:
        a_ct = 0
        bc_ct = 0 s[i] == "A" s[i] s i "A" a_ct += 1 a_ct 1 elif s[i] == "B":
        if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
     s[i] == "B" s[i] s i "B" if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
     s[i+1] == "C" s[i+1] s i+1 i 1 "C" bc_ct += 1 bc_ct 1 ans += a_ct ans a_ct flag = 1 flag 1 a_ct = 0 a_ct 0 bc_ct = 0 bc_ct 0 a_ct = 0 a_ct 0 bc_ct = 0 bc_ct 0 print(ans) print ans flag = 0 0 flag a_ct = 0 0 a_ct a_ct = 0 0 a_ct s = readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') s a_ct += 1 1 a_ct bc_ct = 0 0 bc_ct bc_ct = 0 0 bc_ct def even(n): return 1 if n%2==0 else 0 def even(n): return 1 if n%2==0 else 0 even flag = 0 0 flag readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline ans = 0 0 ans bc_ct += 1 1 bc_ct flag = 1 1 flag bc_ct = 0 0 bc_ct ans += a_ct a_ct ans a_ct = 0 0 a_ct
#AGC034-B ABC
"""
ABC→BCA
ABCBC→BCABC→BCBCA
AABC→ABCA→BCAA

"BC"の文字列は絶対に不変で、これが"A"を左から右にキャリーする役割を持つ。
それ以外の文字列、Bの後にCが無い状態もしくは、Cの前にBが無い時、キャリーが終わる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
ans = 0 
a_ct = 0
bc_ct = 0
flag = 0
for i in range(len(s)-1):
    if flag:
        flag = 0
        continue
    if s[i] == "A":
        a_ct += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            bc_ct += 1
            ans += a_ct
            flag = 1
        else:
            a_ct = 0
            bc_ct = 0
    else:
        a_ct = 0
        bc_ct = 0

print(ans)