s=gets.chop l=s.size p (l.times.map{|i| eval (s[i..-1]+s[0...i]).gsub /011/,'11'if s[i]=~/\d/&&s[i-1]=~/\d/ }-[p]).max