S = gets.chomp
c = 0
loop do
  (S.length-2).times do |i|
    s = S[i, 3]
    if s == "ABC"
      S[i] = "B"
      S[i+1] = "C"
      S[i+2] = "A"
      c += 1
    end
  end
  if !S.include?("ABC")
    p c
    break
  end
end