s = input()
if 'BC' not in s:
  print(0)
  import sys
  sys.exit()
t = s.split('BC')
m = 0
ans = 0
for l in t[:-1]:
  cnt = 0
  for i in range(len(l)-1,-1,-1):
    if l[i]!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m
print(ans) s = input() s input() input if 'BC' not in s:
  print(0)
  import sys
  sys.exit() 'BC' not in s 'BC' s print(0) print 0 import sys sys sys.exit() sys.exit sys exit t = s.split('BC') t s.split('BC') s.split s split 'BC' m = 0 m 0 ans = 0 ans 0 for l in t[:-1]:
  cnt = 0
  for i in range(len(l)-1,-1,-1):
    if l[i]!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m l t[:-1] t :-1 -1 cnt = 0 cnt 0 for i in range(len(l)-1,-1,-1):
    if l[i]!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m i range(len(l)-1,-1,-1) range len(l)-1 len(l) len l 1 -1 -1 if l[i]!='A':
      ans += cnt
      m = cnt
      break
     l[i]!='A' l[i] l i 'A' ans += cnt ans cnt m = cnt m cnt break cnt += 1 cnt 1 m += cnt m cnt ans += m ans m print(ans) print ans m = cnt cnt m ans = 0 0 ans s = input() input() s cnt += 1 1 cnt m += cnt cnt m cnt = 0 0 cnt ans += m m ans m = 0 0 m ans += cnt cnt ans t = s.split('BC') s.split('BC') t
s = input()
if 'BC' not in s:
  print(0)
  import sys
  sys.exit()
t = s.split('BC')
m = 0
ans = 0
for l in t[:-1]:
  cnt = 0
  for i in range(len(l)-1,-1,-1):
    if l[i]!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m
print(ans)
