import queue

k = int(eval(input()))



q = queue.Queue()

num = 0

for i in range(1,10):

    q.put(i)



while num<k:

    i = q.get()

    l = i%10

    if l!=0:

        q.put(i*10+l-1)

    q.put(i*10+l)

    if l!=9:

        q.put(i*10+l+1)

    num += 1



print(i)

k = int(eval(input()))



lst = [1,2,3,4,5,6,7,8,9]

count = 0



for i in range(k):

    num = lst[count]

    if num%10!=0:

        lst.append(num*10+num%10-1)

    lst.append(num*10+num%10)

    if num%10!=9:

        lst.append(num*10+num%10+1)

    count += 1



print((lst[k-1]))

import queue

k = int(eval(input()))
q = queue.Queue()
num = 0
for i in range(1, 10):
    q.put(i)
while num < k:
    i = q.get()
    l = i % 10
    if l != 0:
        q.put(i * 10 + l - 1)
    q.put(i * 10 + l)
    if l != 9:
        q.put(i * 10 + l + 1)
    num += 1
print(i)

k = int(eval(input()))
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 0
for i in range(k):
    num = lst[count]
    if num % 10 != 0:
        lst.append(num * 10 + num % 10 - 1)
    lst.append(num * 10 + num % 10)
    if num % 10 != 9:
        lst.append(num * 10 + num % 10 + 1)
    count += 1
print((lst[k - 1]))

-import queue - -q = queue.Queue() -num = 0 -for i in range(1, 10): -    q.put(i) -while num < k: -    i = q.get() -    l = i % 10 -    if l != 0: -        q.put(i * 10 + l - 1) -    q.put(i * 10 + l) -    if l != 9: -        q.put(i * 10 + l + 1) -    num += 1 -print(i) +lst = [1, 2, 3, 4, 5, 6, 7, 8, 9] +count = 0 +for i in range(k): +    num = lst[count] +    if num % 10 != 0: +        lst.append(num * 10 + num % 10 - 1) +    lst.append(num * 10 + num % 10) +    if num % 10 != 9: +        lst.append(num * 10 + num % 10 + 1) +    count += 1 +print((lst[k - 1]))