n = int(input()) steps = 0 while n != 1: if n % 2 == 0: # Divide by the maximum possible power of 2 in one step while n % 2 == 0: n //= 2 steps += 1 else: found = False # Check up to s=40 which covers 2^40, sufficient for N up to 1e9 for s in range(1, 40): power = (1 << s) - 1 # 2^s - 1 if power % n == 0: steps += 2 n = 1 found = True break if not found: # Use k=1 and then divide by 2 until odd n += 1 cnt = 0 while n % 2 == 0: n //= 2 steps += 2 print(steps)