def dfs(s,l):

  if s!="":

    if len(s)>10 or s[0]=="0":

      return

  if s!="":

    l.append(int(s))

  for c in "0123456789":

    if s!="":

      if abs(int(s[-1])-int(c))<=1:

        dfs(s+c,l)

    else:

      if c!="0":

        dfs(s+c,l)



k=int(eval(input()))

l=[]

dfs("",l)

l.sort()

print((l[k-1]))

import sys

sys.setrecursionlimit(10000000)

def dfs(s):

  if len(s)==11:

    return

  if s!="":

    a.append(int(s))

  for c in "0123456789":

    if s=="" and c=="0":continue

    if len(s)>0:

      if abs(ord(s[-1])-ord(c))<=1:

        dfs(s+c)

    else:

        dfs(s+c)

k=int(eval(input()))

a=[]

dfs("")

a=list(set(a))

a.sort()

print((a[k-1]))

def dfs(s, l):
    if s != "":
        if len(s) > 10 or s[0] == "0":
            return
    if s != "":
        l.append(int(s))
    for c in "0123456789":
        if s != "":
            if abs(int(s[-1]) - int(c)) <= 1:
                dfs(s + c, l)
        else:
            if c != "0":
                dfs(s + c, l)


k = int(eval(input()))
l = []
dfs("", l)
l.sort()
print((l[k - 1]))

import sys

sys.setrecursionlimit(10000000)


def dfs(s):
    if len(s) == 11:
        return
    if s != "":
        a.append(int(s))
    for c in "0123456789":
        if s == "" and c == "0":
            continue
        if len(s) > 0:
            if abs(ord(s[-1]) - ord(c)) <= 1:
                dfs(s + c)
        else:
            dfs(s + c)


k = int(eval(input()))
a = []
dfs("")
a = list(set(a))
a.sort()
print((a[k - 1]))

-def dfs(s, l): +import sys + +sys.setrecursionlimit(10000000) + + +def dfs(s): +    if len(s) == 11: +        return -        if len(s) > 10 or s[0] == "0": -            return -    if s != "": -        l.append(int(s)) +        a.append(int(s)) -        if s != "": -            if abs(int(s[-1]) - int(c)) <= 1: -                dfs(s + c, l) +        if s == "" and c == "0": +            continue +        if len(s) > 0: +            if abs(ord(s[-1]) - ord(c)) <= 1: +                dfs(s + c) -            if c != "0": -                dfs(s + c, l) +            dfs(s + c) -l = [] -dfs("", l) -l.sort() -print((l[k - 1])) +a = [] +dfs("") +a = list(set(a)) +a.sort() +print((a[k - 1]))