s=gets.chop p ((0..s.size).map{|i|$_=s[i,$$]+s[0,i];eval$_.gsub /011/,'11'if /^\d.*\d$/}-[p]).max