s = gets.chomp
if s[0, 3] == '111' || s[0, 3] == '000'
  s.reverse!
end

c = 0
while s.include?('00') || s.include?('11')
  s.size.times do |i|
    case s[i, 3]
    when '000', '011', '110'
      s[i, 3] = '010'
      break
    when '100', '001', '111'
      s[i, 3] = '101'
      break
    end
  end
  c += 1
end
puts c
