s = gets.chomp.split("")

$count = 0

def abc(s)
  (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"]
     $count += 1
       abc(s[i+2..s.length])
   end
  }
end

abc(s)

puts $count
