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() aa = [1] for i in range(300): 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)) aa = list(set(aa)) aa.sort() print(aa[n-1])