s = list(input())

i = 0
bc = list("BC")

a_cnt = 0
res = 0
i = 0
while i <= len(s)-1:
  if s[i] == "A":
    a_cnt += 1
  elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
  else:
    a_cnt = 0
  i += 1

print(res) s = list(input()) s list(input()) list input() input i = 0 i 0 bc = list("BC") bc list("BC") list "BC" a_cnt = 0 a_cnt 0 res = 0 res 0 i = 0 i 0 while i <= len(s)-1:
  if s[i] == "A":
    a_cnt += 1
  elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
  else:
    a_cnt = 0
  i += 1 i <= len(s)-1 i len(s)-1 len(s) len s 1 if s[i] == "A":
    a_cnt += 1
  elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
  else:
    a_cnt = 0
   s[i] == "A" s[i] s i "A" a_cnt += 1 a_cnt 1 elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
   s[i:i+2] == bc s[i:i+2] s i:i+2 i i+2 i 2 bc res += a_cnt res a_cnt i += 1 i 1 a_cnt = 0 a_cnt 0 i += 1 i 1 print(res) print res a_cnt += 1 1 a_cnt i += 1 1 i i += 1 1 i res += a_cnt a_cnt res a_cnt = 0 0 a_cnt a_cnt = 0 0 a_cnt s = list(input()) list(input()) s i = 0 0 i bc = list("BC") list("BC") bc i = 0 0 i res = 0 0 res
s = list(input())

i = 0
bc = list("BC")

a_cnt = 0
res = 0
i = 0
while i <= len(s)-1:
  if s[i] == "A":
    a_cnt += 1
  elif s[i:i+2] == bc:
    res += a_cnt
    i += 1
  else:
    a_cnt = 0
  i += 1

print(res)