K=int(eval(input()))

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

ans = 0

for i in range(K):

    if ans <=11:

        ans += 1

        continue

    flg = True

    l = len(str(ans))

    for j in range(l-1,-1,-1):

        if 0<j<l-1:

            x,y,z = list(map(int,str(ans)[j-1:j+2]))

            if y!=9 and abs(x-(y+1))<=1 and abs((y+1)-z)<=1:

                ans = int(str(ans)[:j]+''.join([str(max(0,y+1-i)) for i in range(l-j)]))

                flg = False

                break

        elif j==0:

            x,y = list(map(int,str(ans)[:2]))

            if x != 9 and abs(x+1-y) <=1:

                ans = int(''.join([str(max(0,x+1-i))for i in range(l)]))

                flg = False

                break

        else:

            x,y = list(map(int,str(ans)[-2:]))

            if y != 9 and abs(x-(y+1))<=1:

                ans += 1

                flg = False

                break

    if flg:

        ans = 10**l

print(ans)
from collections import deque

K=int(eval(input()))

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

for i in range(K):

    x = ans.popleft()

    mod_x=x%10

    if mod_x != 0:

        ans.append(x*10+mod_x-1)

    ans.append(x*10+mod_x)

    if x%10!=9:

        ans.append(x*10+mod_x+1)

print(x)
K = int(eval(input()))
u12 = [i for i in range(1, 10)]
ans = 0
for i in range(K):
    if ans <= 11:
        ans += 1
        continue
    flg = True
    l = len(str(ans))
    for j in range(l - 1, -1, -1):
        if 0 < j < l - 1:
            x, y, z = list(map(int, str(ans)[j - 1 : j + 2]))
            if y != 9 and abs(x - (y + 1)) <= 1 and abs((y + 1) - z) <= 1:
                ans = int(
                    str(ans)[:j]
                    + "".join([str(max(0, y + 1 - i)) for i in range(l - j)])
                )
                flg = False
                break
        elif j == 0:
            x, y = list(map(int, str(ans)[:2]))
            if x != 9 and abs(x + 1 - y) <= 1:
                ans = int("".join([str(max(0, x + 1 - i)) for i in range(l)]))
                flg = False
                break
        else:
            x, y = list(map(int, str(ans)[-2:]))
            if y != 9 and abs(x - (y + 1)) <= 1:
                ans += 1
                flg = False
                break
    if flg:
        ans = 10**l
print(ans)

from collections import deque

K = int(eval(input()))
ans = deque([i for i in range(1, 10)])
for i in range(K):
    x = ans.popleft()
    mod_x = x % 10
    if mod_x != 0:
        ans.append(x * 10 + mod_x - 1)
    ans.append(x * 10 + mod_x)
    if x % 10 != 9:
        ans.append(x * 10 + mod_x + 1)
print(x)

+from collections import deque + -u12 = [i for i in range(1, 10)] -ans = 0 +ans = deque([i for i in range(1, 10)]) -    if ans <= 11: -        ans += 1 -        continue -    flg = True -    l = len(str(ans)) -    for j in range(l - 1, -1, -1): -        if 0 < j < l - 1: -            x, y, z = list(map(int, str(ans)[j - 1 : j + 2])) -            if y != 9 and abs(x - (y + 1)) <= 1 and abs((y + 1) - z) <= 1: -                ans = int( -                    str(ans)[:j] -                    + "".join([str(max(0, y + 1 - i)) for i in range(l - j)]) -                ) -                flg = False -                break -        elif j == 0: -            x, y = list(map(int, str(ans)[:2])) -            if x != 9 and abs(x + 1 - y) <= 1: -                ans = int("".join([str(max(0, x + 1 - i)) for i in range(l)])) -                flg = False -                break -        else: -            x, y = list(map(int, str(ans)[-2:])) -            if y != 9 and abs(x - (y + 1)) <= 1: -                ans += 1 -                flg = False -                break -    if flg: -        ans = 10**l -print(ans) +    x = ans.popleft() +    mod_x = x % 10 +    if mod_x != 0: +        ans.append(x * 10 + mod_x - 1) +    ans.append(x * 10 + mod_x) +    if x % 10 != 9: +        ans.append(x * 10 + mod_x + 1) +print(x)