from collections import deque

K = int(eval(input()))



que = deque(list(map(str, list(range(1, 10)))))

while K > 1:

    n = que.popleft()

    K -= 1

    R = int(n[-1])

    for r in (R - 1, R, R + 1):

        if 0 <= r <= 9:

            que.append(n + str(r))



print((que[0]))

from collections import deque



K = int(eval(input()))



que = deque([i for i in range(1, 10)])

ans = []

while len(ans) <= K + 10:

    now = que.popleft()

    ans.append(now)



    b = now % 10

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

        que.append(now * 10 + i)



ans.sort()

print((ans[K - 1]))

from collections import deque

K = int(eval(input()))
que = deque(list(map(str, list(range(1, 10)))))
while K > 1:
    n = que.popleft()
    K -= 1
    R = int(n[-1])
    for r in (R - 1, R, R + 1):
        if 0 <= r <= 9:
            que.append(n + str(r))
print((que[0]))

from collections import deque

K = int(eval(input()))
que = deque([i for i in range(1, 10)])
ans = []
while len(ans) <= K + 10:
    now = que.popleft()
    ans.append(now)
    b = now % 10
    for i in range(max(0, b - 1), min(10, b + 2)):
        que.append(now * 10 + i)
ans.sort()
print((ans[K - 1]))

-que = deque(list(map(str, list(range(1, 10))))) -while K > 1: -    n = que.popleft() -    K -= 1 -    R = int(n[-1]) -    for r in (R - 1, R, R + 1): -        if 0 <= r <= 9: -            que.append(n + str(r)) -print((que[0])) +que = deque([i for i in range(1, 10)]) +ans = [] +while len(ans) <= K + 10: +    now = que.popleft() +    ans.append(now) +    b = now % 10 +    for i in range(max(0, b - 1), min(10, b + 2)): +        que.append(now * 10 + i) +ans.sort() +print((ans[K - 1]))