def func(x):
    y = bin(x)
    for i in range(len(y),0,-1):
        n = ''.join(['1'] * i)
        if n in y:
            return i
    return 0

while True:
    try:
        a = int(input())
        b = func(a)
        print(b)
    except:
        break