strings = gets.chomp.split('')
count = 0

loop do
  (strings.length-2).times do |i|
    s = strings[i, 3]
    if s.join == "ABC"
      strings[i] = "B"
      strings[i+1] = "C"
      strings[i+2] = "A"
      count += 1
    end
  end
  if !strings.join.include?("ABC")
    p count
    break
  end
end