import sys

from string import digits



k = int(sys.stdin.readline().rstrip())



def main():

    if k <= 9:

        print(k)

        return

    res = list(digits[1:])

    r = k - 9

    nex = []

    while True:

        for n in res:

            o = ord(n[-1])

            for i in range(-1, 2):

                d = chr(o + i)

                if d < '0' or d > '9': continue

                nex.append(n + d)

                r -= 1

                if not r:

                    print((nex[-1]))

                    return

        res = nex.copy()

        nex.clear()



if __name__ ==  '__main__':

    main()
import sys



k = int(sys.stdin.readline().rstrip())



def main(k):

    if k <= 9:

        print(k)

        return

    res = list(range(1, 10))

    k -= 9

    while True:

        nex = []

        for n in res:

            r = n % 10

            n *= 10

            for i in range(-1, 2):

                if 0 <= r + i <= 9:

                    nex.append(n + r + i)

                    k -= 1

                    if not k:

                        print((nex[-1]))

                        return

        res = nex.copy()



if __name__ == '__main__':

    main(k)
import sys
from string import digits

k = int(sys.stdin.readline().rstrip())


def main():
    if k <= 9:
        print(k)
        return
    res = list(digits[1:])
    r = k - 9
    nex = []
    while True:
        for n in res:
            o = ord(n[-1])
            for i in range(-1, 2):
                d = chr(o + i)
                if d < "0" or d > "9":
                    continue
                nex.append(n + d)
                r -= 1
                if not r:
                    print((nex[-1]))
                    return
        res = nex.copy()
        nex.clear()


if __name__ == "__main__":
    main()

import sys

k = int(sys.stdin.readline().rstrip())


def main(k):
    if k <= 9:
        print(k)
        return
    res = list(range(1, 10))
    k -= 9
    while True:
        nex = []
        for n in res:
            r = n % 10
            n *= 10
            for i in range(-1, 2):
                if 0 <= r + i <= 9:
                    nex.append(n + r + i)
                    k -= 1
                    if not k:
                        print((nex[-1]))
                        return
        res = nex.copy()


if __name__ == "__main__":
    main(k)

-from string import digits -def main(): +def main(k): -    res = list(digits[1:]) -    r = k - 9 -    nex = [] +    res = list(range(1, 10)) +    k -= 9 +        nex = [] -            o = ord(n[-1]) +            r = n % 10 +            n *= 10 -                d = chr(o + i) -                if d < "0" or d > "9": -                    continue -                nex.append(n + d) -                r -= 1 -                if not r: -                    print((nex[-1])) -                    return +                if 0 <= r + i <= 9: +                    nex.append(n + r + i) +                    k -= 1 +                    if not k: +                        print((nex[-1])) +                        return -        nex.clear() -    main() +    main(k)