s = input()
s = s.replace("BC", "D")
gomi = 0
c = 0
for i in s:
  if i == "A":
      c += 1
  elif i == "D":
      gomi += c
  else:
      c = 0
print(gomi) s = input() s input() input s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" gomi = 0 gomi 0 c = 0 c 0 for i in s:
  if i == "A":
      c += 1
  elif i == "D":
      gomi += c
  else:
      c = 0 i s if i == "A":
      c += 1
  elif i == "D":
      gomi += c
  else:
      c = 0 i == "A" i "A" c += 1 c 1 elif i == "D":
      gomi += c
   i == "D" i "D" gomi += c gomi c c = 0 c 0 print(gomi) print gomi s = s.replace("BC", "D") s.replace("BC", "D") s c = 0 0 c c = 0 0 c c += 1 1 c gomi = 0 0 gomi s = input() input() s gomi += c c gomi
s = input()
s = s.replace("BC", "D")
gomi = 0
c = 0
for i in s:
  if i == "A":
      c += 1
  elif i == "D":
      gomi += c
  else:
      c = 0
print(gomi)