k = int(eval(input()))

count = 9

from collections import deque

que = deque([1,2,3,4,5,6,7,8,9])

if k<10:

    print(k)

    exit()

while que:

    v = que.popleft()

    matu = v%10

    for i in range(10):

        if abs(matu-i)<=1:

            que.append(v*10+i)

            count +=1

            if count == k:

                print((que.pop()))

                exit()

from collections import deque

k = int(eval(input()))

count = 0

que = deque([1,2,3,4,5,6,7,8,9])

while que:

    q = que.popleft()

    count +=1

    if count == k:

        print(q)

        exit()

    tmp = q%10

    if tmp == 0:

        for i in range(0,2):

            nq = q*10+i

            que.append(nq)

    elif tmp == 9:

        for i in range(8,10):

            nq = q*10+i

            que.append(nq)

    else:

        for i in range(tmp-1, tmp+2):

            nq = q * 10 + i

            que.append(nq)
k = int(eval(input()))
count = 9
from collections import deque

que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
if k < 10:
    print(k)
    exit()
while que:
    v = que.popleft()
    matu = v % 10
    for i in range(10):
        if abs(matu - i) <= 1:
            que.append(v * 10 + i)
            count += 1
            if count == k:
                print((que.pop()))
                exit()

from collections import deque

k = int(eval(input()))
count = 0
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
while que:
    q = que.popleft()
    count += 1
    if count == k:
        print(q)
        exit()
    tmp = q % 10
    if tmp == 0:
        for i in range(0, 2):
            nq = q * 10 + i
            que.append(nq)
    elif tmp == 9:
        for i in range(8, 10):
            nq = q * 10 + i
            que.append(nq)
    else:
        for i in range(tmp - 1, tmp + 2):
            nq = q * 10 + i
            que.append(nq)

-k = int(eval(input())) -count = 9 +k = int(eval(input())) +count = 0 -if k < 10: -    print(k) -    exit() -    v = que.popleft() -    matu = v % 10 -    for i in range(10): -        if abs(matu - i) <= 1: -            que.append(v * 10 + i) -            count += 1 -            if count == k: -                print((que.pop())) -                exit() +    q = que.popleft() +    count += 1 +    if count == k: +        print(q) +        exit() +    tmp = q % 10 +    if tmp == 0: +        for i in range(0, 2): +            nq = q * 10 + i +            que.append(nq) +    elif tmp == 9: +        for i in range(8, 10): +            nq = q * 10 + i +            que.append(nq) +    else: +        for i in range(tmp - 1, tmp + 2): +            nq = q * 10 + i +            que.append(nq)