s = input()
new_s = s.replace('BC', 'X')

count = 0
a = 0
for si in list(new_s):
  if si == 'A':
    count += 1
  elif si == 'X':
    a += count
  else:
    count = 0
print(a) s = input() s input() input new_s = s.replace('BC', 'X') new_s s.replace('BC', 'X') s.replace s replace 'BC' 'X' count = 0 count 0 a = 0 a 0 for si in list(new_s):
  if si == 'A':
    count += 1
  elif si == 'X':
    a += count
  else:
    count = 0 si list(new_s) list new_s if si == 'A':
    count += 1
  elif si == 'X':
    a += count
  else:
    count = 0 si == 'A' si 'A' count += 1 count 1 elif si == 'X':
    a += count
   si == 'X' si 'X' a += count a count count = 0 count 0 print(a) print a count = 0 0 count s = input() input() s count += 1 1 count new_s = s.replace('BC', 'X') s.replace('BC', 'X') new_s count = 0 0 count a = 0 0 a a += count count a
s = input()
new_s = s.replace('BC', 'X')

count = 0
a = 0
for si in list(new_s):
  if si == 'A':
    count += 1
  elif si == 'X':
    a += count
  else:
    count = 0
print(a)