import sys, bisect, math, itertools, string, queue, copy

# import numpy as np

# import scipy

from collections import Counter,defaultdict,deque

from itertools import permutations, combinations

from heapq import heappop, heappush

from fractions import gcd

# input = sys.stdin.readline

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(eval(input()))

def inpm(): return list(map(int,input().split()))

def inpl(): return list(map(int, input().split()))

def inpls(): return list(input().split())

def inplm(n): return list(int(eval(input())) for _ in range(n))

def inplL(n): return [list(eval(input())) for _ in range(n)]

def inplT(n): return [tuple(eval(input())) for _ in range(n)]

def inpll(n): return [list(map(int, input().split())) for _ in range(n)]

def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])



a = []



def g(x):

    for i in range(-1,2):

        last = int(x[-1]) + i

        if int(''.join(x)) <= 3234566667 and last != -1 and last != 10:

            y = copy.copy(x)

            y.append(str(last))

            f(y)

    return



def f(x):

    a.append(int(''.join(x)))

    g(x)

    return



f(['1'])

f(['2'])

f(['3'])

f(['4'])

f(['5'])

f(['6'])

f(['7'])

f(['8'])

f(['9'])

a.sort()



def main():

    n = inp()

    print((a[n-1]))

    

if __name__ == "__main__":

    main()
import sys, bisect, math, itertools, string, queue, copy

# import numpy as np

# import scipy

from collections import Counter,defaultdict,deque

from itertools import permutations, combinations

from heapq import heappop, heappush

from fractions import gcd

# input = sys.stdin.readline

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(eval(input()))

def inpm(): return list(map(int,input().split()))

def inpl(): return list(map(int, input().split()))

def inpls(): return list(input().split())

def inplm(n): return list(int(eval(input())) for _ in range(n))

def inplL(n): return [list(eval(input())) for _ in range(n)]

def inplT(n): return [tuple(eval(input())) for _ in range(n)]

def inpll(n): return [list(map(int, input().split())) for _ in range(n)]

def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])



a = []



def g(x):

    for i in range(-1,2):

        last = (x%10) + i

        if x <= 3234566667 and last != -1 and last != 10:

            f(10*x+last)

def f(x):

    a.append(x)

    g(x)



for i in range(1,10):

    f(i)

a.sort()



def main():

    n = inp()

    print((a[n-1]))

    

if __name__ == "__main__":

    main()
import sys, bisect, math, itertools, string, queue, copy

# import numpy as np
# import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9 + 7


def inp():
    return int(eval(input()))


def inpm():
    return list(map(int, input().split()))


def inpl():
    return list(map(int, input().split()))


def inpls():
    return list(input().split())


def inplm(n):
    return list(int(eval(input())) for _ in range(n))


def inplL(n):
    return [list(eval(input())) for _ in range(n)]


def inplT(n):
    return [tuple(eval(input())) for _ in range(n)]


def inpll(n):
    return [list(map(int, input().split())) for _ in range(n)]


def inplls(n):
    return sorted([list(map(int, input().split())) for _ in range(n)])


a = []


def g(x):
    for i in range(-1, 2):
        last = int(x[-1]) + i
        if int("".join(x)) <= 3234566667 and last != -1 and last != 10:
            y = copy.copy(x)
            y.append(str(last))
            f(y)
    return


def f(x):
    a.append(int("".join(x)))
    g(x)
    return


f(["1"])
f(["2"])
f(["3"])
f(["4"])
f(["5"])
f(["6"])
f(["7"])
f(["8"])
f(["9"])
a.sort()


def main():
    n = inp()
    print((a[n - 1]))


if __name__ == "__main__":
    main()

import sys, bisect, math, itertools, string, queue, copy

# import numpy as np
# import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9 + 7


def inp():
    return int(eval(input()))


def inpm():
    return list(map(int, input().split()))


def inpl():
    return list(map(int, input().split()))


def inpls():
    return list(input().split())


def inplm(n):
    return list(int(eval(input())) for _ in range(n))


def inplL(n):
    return [list(eval(input())) for _ in range(n)]


def inplT(n):
    return [tuple(eval(input())) for _ in range(n)]


def inpll(n):
    return [list(map(int, input().split())) for _ in range(n)]


def inplls(n):
    return sorted([list(map(int, input().split())) for _ in range(n)])


a = []


def g(x):
    for i in range(-1, 2):
        last = (x % 10) + i
        if x <= 3234566667 and last != -1 and last != 10:
            f(10 * x + last)


def f(x):
    a.append(x)
    g(x)


for i in range(1, 10):
    f(i)
a.sort()


def main():
    n = inp()
    print((a[n - 1]))


if __name__ == "__main__":
    main()

-        last = int(x[-1]) + i -        if int("".join(x)) <= 3234566667 and last != -1 and last != 10: -            y = copy.copy(x) -            y.append(str(last)) -            f(y) -    return +        last = (x % 10) + i +        if x <= 3234566667 and last != -1 and last != 10: +            f(10 * x + last) -    a.append(int("".join(x))) +    a.append(x) -    return -f(["1"]) -f(["2"]) -f(["3"]) -f(["4"]) -f(["5"]) -f(["6"]) -f(["7"]) -f(["8"]) -f(["9"]) +for i in range(1, 10): +    f(i)