import sys

from collections import deque





def input():

    return sys.stdin.readline().strip()





def main():

    K = int(eval(input()))

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

    for _ in range(K - 1):

        a = ans.popleft()

        if a % 10 == 0:

            ans.append(a * 10)

            ans.append(a * 10 + 1)

        elif a % 10 == 9:

            ans.append(a * 10 + 8)

            ans.append(a * 10 + 9)

        else:

            w = a % 10

            ans.append(a * 10 + w - 1)

            ans.append(a * 10 + w)

            ans.append(a * 10 + w + 1)

    print((ans.popleft()))





if __name__ == "__main__":

    main()

import sys

from collections import deque





def input():

    return sys.stdin.readline().strip()





sys.setrecursionlimit(20000000)



MOD = 10 ** 9 + 7

INF = float("inf")





def main():

    K = int(eval(input()))

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

    for i in range(K):

        d = q.popleft()

        a = d % 10

        if a == 0:

            q.append(d * 10)

            q.append(d * 10 + 1)

        elif a == 9:

            q.append(d * 10 + a - 1)

            q.append(d * 10 + a)

        else:

            q.append(d * 10 + a - 1)

            q.append(d * 10 + a)

            q.append(d * 10 + a + 1)

    print(d)





if __name__ == "__main__":

    main()

import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


def main():
    K = int(eval(input()))
    ans = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
    for _ in range(K - 1):
        a = ans.popleft()
        if a % 10 == 0:
            ans.append(a * 10)
            ans.append(a * 10 + 1)
        elif a % 10 == 9:
            ans.append(a * 10 + 8)
            ans.append(a * 10 + 9)
        else:
            w = a % 10
            ans.append(a * 10 + w - 1)
            ans.append(a * 10 + w)
            ans.append(a * 10 + w + 1)
    print((ans.popleft()))


if __name__ == "__main__":
    main()

import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)
MOD = 10**9 + 7
INF = float("inf")


def main():
    K = int(eval(input()))
    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
    for i in range(K):
        d = q.popleft()
        a = d % 10
        if a == 0:
            q.append(d * 10)
            q.append(d * 10 + 1)
        elif a == 9:
            q.append(d * 10 + a - 1)
            q.append(d * 10 + a)
        else:
            q.append(d * 10 + a - 1)
            q.append(d * 10 + a)
            q.append(d * 10 + a + 1)
    print(d)


if __name__ == "__main__":
    main()

+sys.setrecursionlimit(20000000) +MOD = 10**9 + 7 +INF = float("inf") + + -    ans = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) -    for _ in range(K - 1): -        a = ans.popleft() -        if a % 10 == 0: -            ans.append(a * 10) -            ans.append(a * 10 + 1) -        elif a % 10 == 9: -            ans.append(a * 10 + 8) -            ans.append(a * 10 + 9) +    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) +    for i in range(K): +        d = q.popleft() +        a = d % 10 +        if a == 0: +            q.append(d * 10) +            q.append(d * 10 + 1) +        elif a == 9: +            q.append(d * 10 + a - 1) +            q.append(d * 10 + a) -            w = a % 10 -            ans.append(a * 10 + w - 1) -            ans.append(a * 10 + w) -            ans.append(a * 10 + w + 1) -    print((ans.popleft())) +            q.append(d * 10 + a - 1) +            q.append(d * 10 + a) +            q.append(d * 10 + a + 1) +    print(d)