k = int(eval(input()))

a = []





def dfs(x):

    a.append(x)

    if x > 3234566667:

        return

    for i in range(10):

        if abs(x % 10 - i) <= 1:

            dfs(x * 10 + i)





for i in range(1, 10):

    dfs(i)

a = sorted(a)

print((a[k - 1]))

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    k = int(eval(input()))

    res = []



    def dfs(x):

        res.append(x)

        if len(str(x)) == 10:

            return



        for i in range(10):

            if abs(x % 10 - i) <= 1:

                dfs(x * 10 + i)



        return



    for i in range(1, 10):

        dfs(i)

    res.sort()

    print((res[k - 1]))





if __name__ == '__main__':

    resolve()

k = int(eval(input()))
a = []


def dfs(x):
    a.append(x)
    if x > 3234566667:
        return
    for i in range(10):
        if abs(x % 10 - i) <= 1:
            dfs(x * 10 + i)


for i in range(1, 10):
    dfs(i)
a = sorted(a)
print((a[k - 1]))

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    k = int(eval(input()))
    res = []

    def dfs(x):
        res.append(x)
        if len(str(x)) == 10:
            return
        for i in range(10):
            if abs(x % 10 - i) <= 1:
                dfs(x * 10 + i)
        return

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


if __name__ == "__main__":
    resolve()

-k = int(eval(input())) -a = [] +import sys + +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 -def dfs(x): -    a.append(x) -    if x > 3234566667: +def resolve(): +    k = int(eval(input())) +    res = [] + +    def dfs(x): +        res.append(x) +        if len(str(x)) == 10: +            return +        for i in range(10): +            if abs(x % 10 - i) <= 1: +                dfs(x * 10 + i) -    for i in range(10): -        if abs(x % 10 - i) <= 1: -            dfs(x * 10 + i) + +    for i in range(1, 10): +        dfs(i) +    res.sort() +    print((res[k - 1])) -for i in range(1, 10): -    dfs(i) -a = sorted(a) -print((a[k - 1])) +if __name__ == "__main__": +    resolve()