def generate(K): res=[] for i in range(1,10): for j in range(i+1,10): s=str(i)+str(j)*K res.append(int(s)) return res N=int(input()) K=1 A=[] while(len(A)<=N): A+=generate(K) K+=1 A.sort() print(A[N-1])