N = int(input()) N -= 1 loop = [] for i in range(1, 10): for j in range(i+1, 10): loop.append([str(i), str(j)]) select = N % len(loop) mul = N // len(loop) print(''.join(loop[select][0] + loop[select][1]*(mul+1)))