mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline D = int(input()) ok = D ng = 0 mid = (ok+ng)//2 while ok - ng > 1: tmp = 0 x = mid while x: tmp += x x //= 2 if tmp >= D: ok = mid else: ng = mid mid = (ok+ng)//2 print(ok) if __name__ == '__main__': main()