while True:
try:
n = int(input())
bin_str = bin(n)
max_len = 0
for i in range(len(bin_str)):
if bin_str[i] != '1':
continue
for j in range(i, len(bin_str)):
if bin_str[i: j + 1].count('1') == len(bin_str[i: j + 1]):
if len(bin_str[i: j + 1]) > max_len:
max_len = len(bin_str[i: j + 1])
print(max_len)
except:
break