N = int(input()) l = [] for i in range(1,9): for j in range(i + 1,10): l.append(i * 10 + j) l.sort() n = len(l) N -= 1 q = N // n r = N % n a = l[r] b = a % 10 for _ in range(q): a *= 10 a += b print(a)