s = gets.chomp

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

  sum += 1
  tmp_s = s[0...index] + 'BC'
  while true
    i = tmp_s.index('ABC')
    if i == nil
      break
    end
    sum += 1
    tmp_s = tmp_s[0...i] + 'BC'
  end
  s = 'A' + s[index+3...s.size]
end
puts sum
