MOD = 10 ** 9 + 7

INF = 10 ** 11

import sys

sys.setrecursionlimit(100000000)



K = int(eval(input()))



lunlun = []

def dfs(i,before):

    if i == 11:

        return

    lunlun.append(before)

    back = before%10

    for j in range(-1,2):

        t = back + j

        if 0 <= t < 10:

            dfs(i + 1,before*10 + t)



for i in range(1,10):

    dfs(1,i)

lunlun.sort()

print((lunlun[K - 1]))

import sys

sys.setrecursionlimit(10000000)

MOD = 10 ** 9 + 7

INF = 10 ** 15



Lunlun = []

K = int(eval(input()))



def dfs(i,before):

    if i == 10:

        return

    Lunlun.append(before)

    x = before%10

    for d in (-1,0,1):

        y = x + d

        if y < 0 or y >= 10:

            continue

        dfs(i + 1,before*10 + y)



for i in range(1,10):

    dfs(0,i)

Lunlun.sort()

ans = Lunlun[K - 1]

print(ans)
MOD = 10**9 + 7
INF = 10**11
import sys

sys.setrecursionlimit(100000000)
K = int(eval(input()))
lunlun = []


def dfs(i, before):
    if i == 11:
        return
    lunlun.append(before)
    back = before % 10
    for j in range(-1, 2):
        t = back + j
        if 0 <= t < 10:
            dfs(i + 1, before * 10 + t)


for i in range(1, 10):
    dfs(1, i)
lunlun.sort()
print((lunlun[K - 1]))

import sys

sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
Lunlun = []
K = int(eval(input()))


def dfs(i, before):
    if i == 10:
        return
    Lunlun.append(before)
    x = before % 10
    for d in (-1, 0, 1):
        y = x + d
        if y < 0 or y >= 10:
            continue
        dfs(i + 1, before * 10 + y)


for i in range(1, 10):
    dfs(0, i)
Lunlun.sort()
ans = Lunlun[K - 1]
print(ans)

-MOD = 10**9 + 7 -INF = 10**11 -sys.setrecursionlimit(100000000) +sys.setrecursionlimit(10000000) +MOD = 10**9 + 7 +INF = 10**15 +Lunlun = [] -lunlun = [] -    if i == 11: +    if i == 10: -    lunlun.append(before) -    back = before % 10 -    for j in range(-1, 2): -        t = back + j -        if 0 <= t < 10: -            dfs(i + 1, before * 10 + t) +    Lunlun.append(before) +    x = before % 10 +    for d in (-1, 0, 1): +        y = x + d +        if y < 0 or y >= 10: +            continue +        dfs(i + 1, before * 10 + y) -    dfs(1, i) -lunlun.sort() -print((lunlun[K - 1])) +    dfs(0, i) +Lunlun.sort() +ans = Lunlun[K - 1] +print(ans)