import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n = ni() if n == 1: print('1') exit() if n == 2: print('3') exit() m = 2 i = 2 for h in range(3,1000000000): o = m + (h-2)*(h-1)//2+1 #print(o,h) if o > n: i = h break m = o aa = [] i -= 2 for j in range(i+1): for k in range(i-j+1): a = '1' a += '1'*k a += '0'*j a += '1'*(i-j-k) a += '1' aa.append(int(a,2)) if j == 0: break aa.sort() print(aa[n-m-1])