function solution(num){
let str = num.toString(2);
let arr=str.split('0')
let result = 0
for(let i=0; i<arr.length; i++){
if(arr[i].length > result){
result = arr[i].length
}
}
return result
}
let line
while(line = parseInt(readline())){
console.log(solution(line))
}