from collections import deque N = int(input()) deq = deque() cnt = 0 for a in range(1,9): for b in range(a+1,10): deq.append((10*a + b, b)) cnt += 1 if N <= cnt: print(deq[N-1]) else: while cnt < N: a,b = deq.popleft() X = 10*a + b deq.append((X,b)) cnt += 1 if cnt == N: print(X) break