S = gets.chomp

stack = []
ans = 0

S.each_char.with_index do |s, idx|
  stack << s

  while stack[(idx - 2)..(idx)] == %w(A B C)
    stack[(idx - 2)..(idx)] = %w(B C A)
    ans += 1

    # p [(idx - 2)..(idx), (idx-5)..(idx-3)]
    idx = idx - 1
  end

  # p stack
end

puts ans
