def make(n, now):

    global cnt, k

    # print(n, now, cnt)

    if n == 0:

        cnt += 1

        if cnt == k:

            return now

        return

    # print(n, now, cnt)

    for i in range(max(0, now[-1] - 1), min(10, now[-1] + 2)):

        ans = make(n - 1, now + [i])

        if ans:

            return ans





k = int(input())

cnt = 0

n = 0

ans = [1]

while cnt < k:

    for i in range(1, 10):

        ans = make(n, [i])

        if ans:

            break

    n += 1

# print(ans)

for i in ans:

    print(i, end = "")

import queue

def solved(n):

    if n <= 9:

        return n

    nums = queue.Queue()

    for i in range(1, 10):

        nums.put(i)

    cnt = 9

    for i in range(cnt, n):

        i_num = nums.get()

        ini_num = i_num % 10

        for j in range(max(0, ini_num - 1), min(10, ini_num + 2)):

            nums.put(i_num * 10 + j)

            cnt += 1

            if cnt == n:

                return i_num * 10 + j

k = int(eval(input()))

num = queue.Queue()

print((solved(k)))
def make(n, now):
    global cnt, k
    # print(n, now, cnt)
    if n == 0:
        cnt += 1
        if cnt == k:
            return now
        return
    # print(n, now, cnt)
    for i in range(max(0, now[-1] - 1), min(10, now[-1] + 2)):
        ans = make(n - 1, now + [i])
        if ans:
            return ans


k = int(input())
cnt = 0
n = 0
ans = [1]
while cnt < k:
    for i in range(1, 10):
        ans = make(n, [i])
        if ans:
            break
    n += 1
# print(ans)
for i in ans:
    print(i, end="")

import queue


def solved(n):
    if n <= 9:
        return n
    nums = queue.Queue()
    for i in range(1, 10):
        nums.put(i)
    cnt = 9
    for i in range(cnt, n):
        i_num = nums.get()
        ini_num = i_num % 10
        for j in range(max(0, ini_num - 1), min(10, ini_num + 2)):
            nums.put(i_num * 10 + j)
            cnt += 1
            if cnt == n:
                return i_num * 10 + j


k = int(eval(input()))
num = queue.Queue()
print((solved(k)))

-def make(n, now): -    global cnt, k -    # print(n, now, cnt) -    if n == 0: -        cnt += 1 -        if cnt == k: -            return now -        return -    # print(n, now, cnt) -    for i in range(max(0, now[-1] - 1), min(10, now[-1] + 2)): -        ans = make(n - 1, now + [i]) -        if ans: -            return ans +import queue -k = int(input()) -cnt = 0 -n = 0 -ans = [1] -while cnt < k: +def solved(n): +    if n <= 9: +        return n +    nums = queue.Queue() -        ans = make(n, [i]) -        if ans: -            break -    n += 1 -# print(ans) -for i in ans: -    print(i, end="") +        nums.put(i) +    cnt = 9 +    for i in range(cnt, n): +        i_num = nums.get() +        ini_num = i_num % 10 +        for j in range(max(0, ini_num - 1), min(10, ini_num + 2)): +            nums.put(i_num * 10 + j) +            cnt += 1 +            if cnt == n: +                return i_num * 10 + j + + +k = int(eval(input())) +num = queue.Queue() +print((solved(k)))