output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      K
attempt: K = int(input())
  
  
  from itertools import product
  
  d = {}
  num_list = []
  for i in range(10):
      nums = set([min((i - 1) % 10, i), i, max((i + 1) % 10, i)])
      #     nums = set([i, min(10-(i-1)%10, i),max((i+1)%10, i)])
      nums = [str(el) for el in nums]
      d[i] = list(product([str(i)], list(nums)))
      d[i] = [int("".join(el)) for el in d[i]]
      d[i] = ["{:02}".format(el) for el in d[i]]
  
      num_list.extend(d[i])
  num_list = sorted(num_list)
  dd = [
      None,
      None,
      d,
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(1, 10)},
      {i: [] for i in range(10)},
  ]
  
  
  def gen_2ll():
      count = 0
      ret = 0
      while int(ret) != 99:
          if int(ret) < 9:
              ret += 1
              count += 1
              yield ret
          else:
              for i in range(1, 10):
                  for ret in d[i]:
                      count += 1
                      yield ret
  
  
  ll2_list = list(gen_2ll())
  
  
  def get_digit_top_list(num_digit, top_num):
      #     print(333, num_digit, top_num)
      if top_num == 0 and num_digit > 2:
          lls = []
          for top_num in range(1, 10):
              lls.extend(get_digit_top_list(num_digit - 1, top_num))
          #             print(44444,lls)
          return ["0" + el for el in lls]
      ret = dd[num_digit][top_num]
      if ret:
          return ret
  
      second_nums = sorted(
          set(
              [
                  min((top_num - 1) % 10, top_num),
                  top_num,
                  max((top_num + 1) % 10, top_num),
              ]
          )
      )
      for second_num in second_nums:
          #         print(111,dd[num_digit][top_num])
          rem_nums = get_digit_top_list(num_digit - 1, int(second_num))
          for rem_num in rem_nums:
              ll = str(top_num) + rem_num
              ret.append(ll)
      dd[num_digit][top_num] = ret
  
      return ret
  
  
  def get_kth_ll(K):
      if K <= len(ll2_list):
          print(ll2_list[K - 1])
      else:
          K -= len(ll2_list)
          for num_digit in range(3, 100):
              for top_num in range(1, 10):
                  _ll_list = get_digit_top_list(num_digit, top_num)
                  #                 print(222, K, len(_ll_list))
                  if K - len(_ll_list) < 0:
                      print(sorted([int(el) for el in _ll_list])[K - 1])
                      return None
                  else:
                      K -= len(_ll_list)
  
  
  get_kth_ll(K)
  
problem_description: Statement
  
  A positive integer X is said to be a lunlun number if and only if the
  following condition is satisfied:
  
    * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.
  
  For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or
  13579 is.
  
  You are given a positive integer K. Find the K-th smallest lunlun number.
samples: [{"input": "15", "output": "23\n    \n\nWe will list the 15 smallest lunlun numbers in ascending order:  \n1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23.  \nThus, the answer is 23.\n\n* * *"}, {"input": "1", "output": "1\n    \n\n* * *"}, {"input": "13", "output": "21\n    \n\n* * *"}, {"input": "100000", "output": "3234566667\n    \n\nNote that the answer may not fit into the 32-bit signed integer type."}]