s = gets.chomp.split("")

$count = 0

def abc(s)
  $check = false
  (s.length - 2).times{ |i|
    if [s[i], s[i + 1], s[i + 2]] == ["A", "B", "C"] then
      s[i], s[i + 1], s[i + 2] = "B", "C", "A"
      i += 2
      $count += 1
      $check = true
    end
  }
  if $check then
    abc(s[1..s.length])
  else
    true
  end
end

abc(s)

puts $count
