#使用正则表达式快速匹配最长“111”型字符串
import re
def dfx(er):
conten, len_max = re.compile("1*"), 0
resoult = re.findall(conten, er)
for i in resoult:
if len(i) > len_max:
len_max = len(i)
return len_max
while True:
try:
print(dfx(bin(int(input()))))
except:
break