import re

s = input()
ans = 0
s = s.replace("BC", "D")
L = re.split('[BC]', s)
for i in L:
  k = len(i)
  temp = 0
  for j in range(k):
    if i[k-1-j] == "D":
      temp += 1
    else:
      ans += temp
print(ans) import re re s = input() s input() input ans = 0 ans 0 s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" L = re.split('[BC]', s) L re.split('[BC]', s) re.split re split '[BC]' s for i in L:
  k = len(i)
  temp = 0
  for j in range(k):
    if i[k-1-j] == "D":
      temp += 1
    else:
      ans += temp i L k = len(i) k len(i) len i temp = 0 temp 0 for j in range(k):
    if i[k-1-j] == "D":
      temp += 1
    else:
      ans += temp j range(k) range k if i[k-1-j] == "D":
      temp += 1
    else:
      ans += temp i[k-1-j] == "D" i[k-1-j] i k-1-j k-1 k 1 j "D" temp += 1 temp 1 ans += temp ans temp print(ans) print ans ans = 0 0 ans k = len(i) len(i) k L = re.split('[BC]', s) re.split('[BC]', s) L temp = 0 0 temp s = input() input() s ans += temp temp ans s = s.replace("BC", "D") s.replace("BC", "D") s temp += 1 1 temp
import re

s = input()
ans = 0
s = s.replace("BC", "D")
L = re.split('[BC]', s)
for i in L:
  k = len(i)
  temp = 0
  for j in range(k):
    if i[k-1-j] == "D":
      temp += 1
    else:
      ans += temp
print(ans)