N = int(input()) ans = [] for a in range(1, 10): for b in range(a+1, 10): X = 10*a + b for _ in range(30000): ans.append(X) X = 10*X+b ans.sort() print(ans[N-1])