N = int(input()) c = 0 nums = [] cnt = 0 N -= 1 c, N = divmod(N, 36) nums = [] for a in range(1, 10): if 9-a <= N: N -= 9-a else: b = a + 1 + N print("".join(map(str, [a] + [b] * (c + 1)))) break