while True:
try:
a = int(input())
b = bin(a)
c = str(b)
res = [0]
for i in range(2, len(c)):
for j in range(i, len(c)):
if c[i:j+1] == "1"*(j-i+1): #连续多个字符可以这么输入!
res.append(j-i+1)
#for p in range(i,j+1):
# if c[p]=='1':#只要存在1就会计数,所以求的是字符串长度
# res.append(j-i+1)
print(max(res))
except:
break