import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = '?' + read().rstrip().decode()[::-1]
ans = 0
cnt = 0
index = 0
for _ in range(len(s) + 1):
    if s[index] == 'C' and s[index + 1] == 'B':
        cnt += 1
        index += 1
    elif s[index] == 'A':
        ans += cnt
    else:
        cnt = 0
    index += 1
    if index >= len(s) - 1:
        break
if s[-1] == 'A':
    ans += cnt
print(ans) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 s = '?' + read().rstrip().decode()[::-1] s '?' + read().rstrip().decode()[::-1] '?' read().rstrip().decode()[::-1] ().rstrip().decode() ().rstrip().decode ().rstrip() ().rstrip () read rstrip decode ::-1 -1 ans = 0 ans 0 cnt = 0 cnt 0 index = 0 index 0 for _ in range(len(s) + 1):
    if s[index] == 'C' and s[index + 1] == 'B':
        cnt += 1
        index += 1
    elif s[index] == 'A':
        ans += cnt
    else:
        cnt = 0
    index += 1
    if index >= len(s) - 1:
        break _ range(len(s) + 1) range len(s) + 1 len(s) len s 1 if s[index] == 'C' and s[index + 1] == 'B':
        cnt += 1
        index += 1
    elif s[index] == 'A':
        ans += cnt
    else:
        cnt = 0
     s[index] == 'C' and s[index + 1] == 'B' s[index] == 'C' s[index] s index 'C' s[index + 1] == 'B' s[index + 1] s index + 1 index 1 'B' cnt += 1 cnt 1 index += 1 index 1 elif s[index] == 'A':
        ans += cnt
     s[index] == 'A' s[index] s index 'A' ans += cnt ans cnt cnt = 0 cnt 0 index += 1 index 1 if index >= len(s) - 1:
        break index >= len(s) - 1 index len(s) - 1 len(s) len s 1 break if s[-1] == 'A':
    ans += cnt s[-1] == 'A' s[-1] s -1 'A' ans += cnt ans cnt print(ans) print ans ans = 0 0 ans cnt = 0 0 cnt index += 1 1 index readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read index += 1 1 index cnt += 1 1 cnt readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline s = '?' + read().rstrip().decode()[::-1] '?' + read().rstrip().decode()[::-1] s index = 0 0 index ans += cnt cnt ans ans += cnt cnt ans cnt = 0 0 cnt
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = '?' + read().rstrip().decode()[::-1]
ans = 0
cnt = 0
index = 0
for _ in range(len(s) + 1):
    if s[index] == 'C' and s[index + 1] == 'B':
        cnt += 1
        index += 1
    elif s[index] == 'A':
        ans += cnt
    else:
        cnt = 0
    index += 1
    if index >= len(s) - 1:
        break
if s[-1] == 'A':
    ans += cnt
print(ans)
