import heapq

K = int(eval(input()))





def fun(h, n):

    tmp = str(n)

    if tmp[-1] == '0':

        heapq.heappush(h, int(tmp + '0'))

        heapq.heappush(h, int(tmp + '1'))

    elif tmp[-1] == '9':

        heapq.heappush(h, int(tmp + '8'))

        heapq.heappush(h, int(tmp + '9'))

    else:

        heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1)))

        heapq.heappush(h, int(tmp + tmp[-1]))

        heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1)))





h = list(range(1, 10))

while K > 0:

    tmp = heapq.heappop(h)

    fun(h, tmp)

    K -= 1

else:

    print(tmp)
import heapq

K = int(eval(input()))





def fun(h, n):

    tmp = n % 10

    if tmp != 0:

        heapq.heappush(h, 10 * n + tmp - 1)

    heapq.heappush(h, 10 * n + tmp)

    if tmp != 9:

        heapq.heappush(h, 10 * n + tmp + 1)





h = list(range(1, 10))

while K > 0:

    n = heapq.heappop(h)

    fun(h, n)

    K -= 1

else:

    print(n)
import heapq

K = int(eval(input()))


def fun(h, n):
    tmp = str(n)
    if tmp[-1] == "0":
        heapq.heappush(h, int(tmp + "0"))
        heapq.heappush(h, int(tmp + "1"))
    elif tmp[-1] == "9":
        heapq.heappush(h, int(tmp + "8"))
        heapq.heappush(h, int(tmp + "9"))
    else:
        heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1)))
        heapq.heappush(h, int(tmp + tmp[-1]))
        heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1)))


h = list(range(1, 10))
while K > 0:
    tmp = heapq.heappop(h)
    fun(h, tmp)
    K -= 1
else:
    print(tmp)

import heapq

K = int(eval(input()))


def fun(h, n):
    tmp = n % 10
    if tmp != 0:
        heapq.heappush(h, 10 * n + tmp - 1)
    heapq.heappush(h, 10 * n + tmp)
    if tmp != 9:
        heapq.heappush(h, 10 * n + tmp + 1)


h = list(range(1, 10))
while K > 0:
    n = heapq.heappop(h)
    fun(h, n)
    K -= 1
else:
    print(n)

-    tmp = str(n) -    if tmp[-1] == "0": -        heapq.heappush(h, int(tmp + "0")) -        heapq.heappush(h, int(tmp + "1")) -    elif tmp[-1] == "9": -        heapq.heappush(h, int(tmp + "8")) -        heapq.heappush(h, int(tmp + "9")) -    else: -        heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1))) -        heapq.heappush(h, int(tmp + tmp[-1])) -        heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1))) +    tmp = n % 10 +    if tmp != 0: +        heapq.heappush(h, 10 * n + tmp - 1) +    heapq.heappush(h, 10 * n + tmp) +    if tmp != 9: +        heapq.heappush(h, 10 * n + tmp + 1) -    tmp = heapq.heappop(h) -    fun(h, tmp) +    n = heapq.heappop(h) +    fun(h, n) -    print(tmp) +    print(n)