S = gets.chomp
s = S.dup
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

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