s = gets.chomp

sum = 0
while true
  index = s.index('ABC')
  if index == nil
    break
  end
  count = 1

  a = s[0...index].scan(/A+$/)[0]
  if a != nil
    count += a.length
  end
  s = 'A' * count + s[index+3...s.size]
  sum += count
end
puts sum
