n = int(input()) ans = 0x3f3f3f3f for i in range(0, 31): u = (1 << i) - n if u < 0: continue c = i while u > 0: u >>= 1 c += 1 ans = min(ans, c) print(ans)