import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) x = 1 if x == n: print(0) exit() for i in range(n): if x * 2 < n: x *= 2 else: print(i + 1 + x * 2 - n) break