D = int(input()) K = 64 ans = D for k in range(1,K+1): high = D low = 1 while abs(high - low) > 1: mid = (high-low) dist = 0 x = mid for n in range(k): dist += x x //= 2 if dist >= D: high = mid else: low = mid v = 0 x = high for i in range(k): v += x x //= 2 if (v == D): ans = high print(ans)