s = gets.chomp

sum = 0
count = s.scan(/(?=ABC)/).count
if count == 0
  puts sum
  exit
end
sum += count
s.gsub!(/ABC/, 'BCA')
while true
  index = s.index('ABC')
  if index == nil
    break
  end

  a = s[0..index].scan(/A+$/)[0]
  bc_count = s[index+1..s.size].match(/^(BC)+/)[0].size / 2
  sum += a.size * bc_count

  s = a + s[(index + bc_count * 2 + 1)...s.size]
end
puts sum
