s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans) s = str(input()) s str(input()) str input() input ans, cnt, i = 0, 0, 0 ans 0 cnt 0 i 0 while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1 i < len(s)-1 i len(s)-1 len(s) len s 1 if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1 s[i] == 'A' s[i] s i 'A' cnt += 1 cnt 1 i += 1 i 1 if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1 s[i:i+2] == 'BC' s[i:i+2] s i:i+2 i i+2 i 2 'BC' ans += cnt ans cnt i += 2 i 2 cnt = 0 cnt 0 i += 1 i 1 print(ans) print ans ans, cnt, i = 0, 0, 0 0 ans cnt, i = 0, 0, 0 0 cnt i += 1 1 i cnt += 1 1 cnt i += 1 1 i i = 0, 0, 0 0 i i += 2 2 i s = str(input()) str(input()) s ans += cnt cnt ans cnt = 0 0 cnt
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)