CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-
# D - Lunlun Number
# 標準入力の取得
K = int(eval(input()))

# 求解
def get_lunlun_number_list(ln_list:list) -> list:
    lunlun_number_list = []
    for ln in ln_list:
        one_place_value = ln % 10
        lunlun_number_list.append(int(str(ln) + str(one_place_value)))
        if one_place_value != 0:
            lunlun_number_list.append(int(str(ln) + str(one_place_value-1)))
        if one_place_value != 9:
            lunlun_number_list.append(int(str(ln) + str(one_place_value+1)))

    return lunlun_number_list

lunlun_number_list = []

lunlun_number_list1 = list(range(1, 10))
lunlun_number_list.extend(lunlun_number_list1)
lunlun_number_list2 = get_lunlun_number_list(lunlun_number_list1)
lunlun_number_list.extend(lunlun_number_list2)
lunlun_number_list3 = get_lunlun_number_list(lunlun_number_list2)
lunlun_number_list.extend(lunlun_number_list3)
lunlun_number_list4 = get_lunlun_number_list(lunlun_number_list3)
lunlun_number_list.extend(lunlun_number_list4)
lunlun_number_list5 = get_lunlun_number_list(lunlun_number_list4)
lunlun_number_list.extend(lunlun_number_list5)
lunlun_number_list6 = get_lunlun_number_list(lunlun_number_list5)
lunlun_number_list.extend(lunlun_number_list6)
lunlun_number_list7 = get_lunlun_number_list(lunlun_number_list6)
lunlun_number_list.extend(lunlun_number_list7)
lunlun_number_list8 = get_lunlun_number_list(lunlun_number_list7)
lunlun_number_list.extend(lunlun_number_list8)
lunlun_number_list9 = get_lunlun_number_list(lunlun_number_list8)
lunlun_number_list.extend(lunlun_number_list9)
lunlun_number_list10 = get_lunlun_number_list(lunlun_number_list9)
lunlun_number_list.extend(lunlun_number_list10)

lunlun_number_list = sorted(lunlun_number_list)

# 結果出力
print((lunlun_number_list[K-1]))

# Optimized solution
# -*- coding: utf-8 -*-
# D - Lunlun Number
# モジュールのインポート
from collections import deque

# 標準入力の取得
K = int(eval(input()))

# 求解処理
# 空のQueueを一つ用意し、1, 2, ・・・, 9を順にEnqueue
que = deque(list(range(1, 10)))
lunlun_number = 0
for k in range(K):
    # Queueに対して、Dequeueを行う
    x = que.popleft()
    # x mod 10 ≠ 0なら、10x + (x mod 10) - 1をEnqueue
    if x % 10 != 0:
        que.append(10*x + (x%10) - 1)
    # 10x + (x mod 10)をEnqueue
    que.append(10*x + (x%10))
    # x mod 10 ≠ 9なら、10x + (x mod 10) + 1をEnqueue
    if x % 10 != 9:
        que.append(10*x + (x%10) + 1)

    # 上の操作をK回実施したときの値がLunlun Number
    lunlun_number = x

print(lunlun_number)
# Original solution
import heapq

k = int(eval(input()))

num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
mae = 0

if k <= 9:
    print(k)
else:
    k -= 9
    q = []
    heapq.heapify(q)
    for i in range(1, 10):
        heapq.heappush(q, i)
    temp = 0
    while temp < 9:
        temp += 1
        num = heapq.heappop(q)
        if temp == 9:
            heapq.heappush(q, num*10 + num_list[(num%10)-1])
            heapq.heappush(q, num*10 + num_list[(num%10)])
        else:
            heapq.heappush(q, num*10 + num_list[(num%10)-1])
            heapq.heappush(q, num*10 + num_list[(num%10)])
            heapq.heappush(q, num*10 + num_list[(num%10)+1])
    while k > 0:
        k -= 1
        num = heapq.heappop(q)
        if num == mae:
            k += 1
            continue
        elif num%10 == 0:
            heapq.heappush(q, num*10 + num_list[(num%10)])
            heapq.heappush(q, num*10 + num_list[(num%10)+1])
        elif num%10 == 9:
            heapq.heappush(q, num*10 + num_list[(num%10)-1])
            heapq.heappush(q, num*10 + num_list[(num%10)])
        else:
            heapq.heappush(q, num*10 + num_list[(num%10)-1])
            heapq.heappush(q, num*10 + num_list[(num%10)])
            heapq.heappush(q, num*10 + num_list[(num%10)+1])
        mae = num
    print(num)


# Optimized solution
from collections import deque

k = int(eval(input()))
cnt = 9
q = deque([])
for i in range(1,10):
    q.append(i)
ans = 0

if k < 10:
    print(k)
else:
    while cnt != k:
        n = q.popleft()
        if n%10 == 0:
            tmp = n*10
            q.append(n*10)
            cnt += 1
            if cnt == k:
                print(tmp)
                break
            q.append(1+tmp)
            cnt += 1
            if cnt == k:
                print((tmp+1))
                break
        elif n%10 == 9:
            tmp = n*10
            q.append(tmp+8)
            cnt+=1
            if cnt == k:
                print((tmp+8))
                break
            q.append(tmp+9)
            cnt += 1
            if cnt == k:
                print((tmp+9))
                break
        else:
            tmp = n%10
            q.append(tmp-1+(n*10))
            cnt += 1
            if cnt ==k:
                print((tmp-1+(n*10)))
                break
            q.append(tmp+(n*10))
            cnt +=1
            if cnt == k:
                print((tmp+(n*10)))
                break
            q.append(tmp+1+(n*10))
            cnt += 1
            if cnt == k:
                print((tmp+1+(n*10)))
                break
# Original solution
from collections import deque
a=int(eval(input()))
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k<=a:
    s=q.popleft()
    if s%10-1>=0:
      q.append(s*10+s%10-1)
      k=k+1
      if k==a:
        print((q.pop()))
    q.append(s*10+s%10)
    k=k+1
    if k==a:
        print((q.pop()))
    if s%10+1<=9:
      q.append(s*10+s%10+1)
      k=k+1
      if k==a:
        print((q.pop()))
  
 
if a<=9:
  print(a)
else:
  dfs(9)
  

# Optimized solution
from collections import deque
q=deque([1,2,3,4,5,6,7,8,9])
n=int(eval(input()))
def check(k):
  while k<=n:
    a=q.popleft()
    if a%10-1>=0:
      q.append(a*10+a%10-1)
      k=k+1 
      if k==n:
        return a*10+a%10-1
    k=k+1
    q.append(a*10+a%10)
    if k==n:
      return a*10+a%10
    if a%10+1<=9:
      q.append(a*10+a%10+1)
      k=k+1
      if k==n:
        return a*10+a%10+1
if n<=9:
  print(n)
else:
  print((check(9)))
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if(discrete) else 10**-8
    if((not left)^f(r)): return r if(left) else r+1
    elif(left^f(l)): return l-1 if(left) else l
    while(r-l>eps):
        h=(l+r)//2 if(discrete) else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if(not discrete) else l if(left) else r

def resolve():
    k = int(eval(input()))

    def check(x):
        if 1 <= x <= 9:
            return x >= k
        x = str(x)
        dp = [[0] * 2 for _ in range(10)]
        s = int(x[0])
        for i in range(1, s):
            dp[i][1] = 1
        dp[s][0] = 1

        x = x[1:]
        for s in x:
            s = int(s)
            ndp = [[0] * 2 for _ in range(10)]
            for d, lt in product(list(range(10)), list(range(2))):
                for nd in [d-1, d, d+1]:
                    if not (0 <= nd <= 9):
                        continue
                    if lt == 0 and s < nd:
                        continue
                    nlt = max(lt, s > nd)
                    ndp[nd][nlt] += dp[d][lt]
            for d in range(1, 10):
                ndp[d][1] += 1
            dp = ndp
        return sum(dp[d][lt] for d, lt in product(list(range(10)), list(range(2)))) >= k


    print((bisection(1, 10**18+1, check, left=False)))
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if(discrete) else 10**-8
    if((not left)^f(r)): return r if(left) else r+1
    elif(left^f(l)): return l-1 if(left) else l
    while(r-l>eps):
        h=(l+r)//2 if(discrete) else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if(not discrete) else l if(left) else r

def resolve():
    k = int(eval(input()))

    def check(x):
        x = str(x)
        dp = [[0] * 2 for _ in range(10)]
        
        s = int(x[0])
        for i in range(1, s):
            dp[i][1] = 1
        dp[s][0] = 1

        x = x[1:]
        for s in x:
            s = int(s)
            ndp = [[0] * 2 for _ in range(10)]
            for d, lt in product(list(range(10)), list(range(2))):
                for nd in [d-1, d, d+1]:
                    if not (0 <= nd <= 9):
                        continue
                    if lt == 0 and s < nd:
                        continue
                    nlt = max(lt, s > nd)
                    ndp[nd][nlt] += dp[d][lt]
            for d in range(1, 10):
                ndp[d][1] += 1
            dp = ndp
        return sum(dp[d][lt] for d, lt in product(list(range(10)), list(range(2)))) >= k

    print((bisection(1, 10**18+1, check, left=False)))
resolve()
# Original solution
from collections import deque
K = int(eval(input()))
Q = deque([i for i in range(1,10)])

for _ in range(K-1):
    q = Q.popleft()
    if q%10 != 0:
        Q.append(10*q+(q%10)-1)
    Q.append(10*q+(q%10))
    if q%10 != 9:
        Q.append(10*q+(q%10)+1)
print((Q.popleft()))

# Optimized solution
from collections import deque
K = int(eval(input()))
Q = deque([i for i in range(1,10)])

for _ in range(K-1):
  q = Q.popleft()
  if q%10 != 0:
    Q.append(q*10+q%10-1)
  Q.append(q*10+q%10)
  if q%10 != 9:
    Q.append(q*10+q%10+1)
print((Q.popleft()))
# Original solution
from collections import deque
K = int(eval(input()))
Q = deque([i for i in range(1,10)])

for _ in range(K-1):
  q = Q.popleft()
  if q%10 != 0:
    Q.append(q*10+q%10-1)
  Q.append(q*10+q%10)
  if q%10 != 9:
    Q.append(q*10+q%10+1)
print((Q.popleft()))

# Optimized solution
from collections import deque
K = int(eval(input()))
q = deque([1,2,3,4,5,6,7,8,9])

for i in range(K):
  num = q.popleft()
  if num%10 != 0:
    q.append(num*10+num%10-1)
  q.append(num*10+num%10)
  if num%10 != 9:
    q.append(num*10+num%10+1)

print(num)
# Original solution
# import numpy as np
# import math
# import copy
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    K = int(eval(input()))

    queue = deque()

    for i in range(1,10):
        queue.append(i)

    for i in range(K):
        x = queue.popleft()
        d = x % 10
        temp = 10 * x + d
        if d != 0:
            queue.append(temp - 1)
        queue.append(temp)
        if d != 9:
            queue.append(temp + 1)

    print(x)



main()


# Optimized solution
# import numpy as np
# import math
# import copy
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    K = int(eval(input()))

    pre = [i for i in range(1,10)]
    now = []

    if K <= 10:
        print(K)
        sys.exit()

    count = 9

    for i in range(2,11):
        for j in pre:
            for k in range(-1,2):
                d = j % 10 + k
                if (d < 0) | (d > 9):
                    continue
                temp = j * 10 + d
                now.append(temp)
                count += 1
                if count == K:
                    print(temp)
                    sys.exit()
        pre = now



main()
# Original solution
import sys

def is_lunlun(x):
    x_str = str(x)
    for i in range(len(x_str)-1):
        if abs(int(x_str[i]) - int(x_str[i+1])) > 1:
            return False
    return True

def main():
    k = int(eval(input()))

    lunlun_map = {
        0: [0, 1],
        1: [0, 1, 2],
        2: [1, 2, 3],
        3: [2, 3, 4],
        4: [3, 4, 5],
        5: [4, 5, 6],
        6: [5, 6, 7],
        7: [6, 7, 8],
        8: [7, 8, 9],
        9: [8, 9]
    }

    if k < 10:
        print(k)
        sys.exit()

    count = 9
    all_lunluns = [list(range(1, 10))]
    i = 0
    while True:
        for lunlun in all_lunluns[i]:
            least = int(str(lunlun)[-1])
            lunluns = []
            for j in lunlun_map[least]:
                new_lunlun = int(str(lunlun) + str(j))
                lunluns.append(new_lunlun)
                count += 1
                if count == k:
                    print(new_lunlun)
                    sys.exit(0)
            all_lunluns.append(lunluns)
        i += 1

if __name__ == "__main__":
    main()

# Optimized solution
# Assumed solution

from collections import deque


def main():
    k = int(eval(input()))

    queue = deque()
    for i in range(1, 10):
        queue.append(i)

    l = 0
    for _ in range(k):
        l = queue.popleft()
        r = l % 10
        if r != 0:
            queue.append(l * 10 + r - 1)
        queue.append(l * 10 + r)
        if r != 9:
            queue.append(l * 10 + r + 1)
    print(l)


if __name__ == "__main__":
    main()
# Original solution
K=int(eval(input()))
u12 = [i for i in range(1,10)]
ans = 0
for i in range(K):
    if ans <=11:
        ans += 1
        continue
    flg = True
    l = len(str(ans))
    for j in range(l-1,-1,-1):
        if 0<j<l-1:
            x,y,z = list(map(int,str(ans)[j-1:j+2]))
            if y!=9 and abs(x-(y+1))<=1 and abs((y+1)-z)<=1:
                ans = int(str(ans)[:j]+''.join([str(max(0,y+1-i)) for i in range(l-j)]))
                flg = False
                break
        elif j==0:
            x,y = list(map(int,str(ans)[:2]))
            if x != 9 and abs(x+1-y) <=1:
                ans = int(''.join([str(max(0,x+1-i))for i in range(l)]))
                flg = False
                break
        else:
            x,y = list(map(int,str(ans)[-2:]))
            if y != 9 and abs(x-(y+1))<=1:
                ans += 1
                flg = False
                break
    if flg:
        ans = 10**l
print(ans)

# Optimized solution
from collections import deque
K=int(eval(input()))
ans =deque([i for i in range(1,10)])
for i in range(K):
    x = ans.popleft()
    mod_x=x%10
    if mod_x != 0:
        ans.append(x*10+mod_x-1)
    ans.append(x*10+mod_x)
    if x%10!=9:
        ans.append(x*10+mod_x+1)
print(x)
# Original solution
k=int(eval(input()))

if k<=9:
    print(k)
    exit(0)

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

i=0
while len(ans)<k:
    v=str(ans[i])
    n=len(v)
    #最後の桁
    v_last=int(v[-1])

    if v_last==0:
        ans.append(int(v+'0'))
        ans.append(int(v+'1'))
    elif v_last==9:
        ans.append(int(v+'8'))
        ans.append(int(v+'9'))
    else:
        ans.append(int(v+str(v_last-1)))
        ans.append(int(v+str(v_last)))
        ans.append(int(v+str(v_last+1)))
    i+=1

print((ans[k-1]))







# Optimized solution
k=int(eval(input()))

if k<=9:
    print(k)
    exit(0)

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

i=0
while len(ans)<k:
    v=ans[i]

    mod=v%10

    if mod==0:
        ans.append(10*v+mod)
        ans.append(10*v+mod+1)
    elif mod==9:
        ans.append(10*v+mod-1)
        ans.append(10*v+mod)
    else:
        ans.append(10*v+mod-1)
        ans.append(10*v+mod)
        ans.append(10*v+mod+1)

    i+=1

print((ans[k-1]))
# Original solution
from collections import deque

K = int(eval(input()))
d = deque([1,2,3,4,5,6,7,8,9])
ansq = deque([1,2,3,4,5,6,7,8,9])

while len(ansq)<=K:
    num = d.popleft()

    if str(num)[-1] == "0":
        d.append(num*10)
        d.append(num*10+1)
        ansq.append(num*10)
        ansq.append(num*10+1)
        continue

    if str(num)[-1] == "9":
        d.append(num*10+8)
        d.append(num*10+9)
        ansq.append(num*10+8)
        ansq.append(num*10+9)
        continue

    d.append(num*10+int(str(num)[-1])-1)
    d.append(num*10+int(str(num)[-1]))
    d.append(num*10+int(str(num)[-1])+1)
    ansq.append(num*10+int(str(num)[-1])-1)
    ansq.append(num*10+int(str(num)[-1]))
    ansq.append(num*10+int(str(num)[-1])+1)
    
print((ansq[K-1]))

# Optimized solution
from collections import deque

K = int(eval(input()))
d = deque([1,2,3,4,5,6,7,8,9])
ansq = deque([1,2,3,4,5,6,7,8,9])

while len(ansq)<=K:
    num = d.popleft()

    if str(num)[-1] == "0":
        da = num*10
        db = num*10+1
        d.append(da)
        d.append(db)
        ansq.append(da)
        ansq.append(db)
        continue

    if str(num)[-1] == "9":
        da = num*10+8
        db = num*10+9
        d.append(da)
        d.append(db)
        ansq.append(da)
        ansq.append(db)
        continue

    da = num*10+int(str(num)[-1])-1
    db = num*10+int(str(num)[-1])
    dc = num*10+int(str(num)[-1])+1
    d.append(da)
    d.append(db)
    d.append(dc)
    ansq.append(da)
    ansq.append(db)
    ansq.append(dc)


print((ansq[K-1]))
# Original solution
k = int(eval(input()))
a = []


def dfs(x):
    a.append(x)
    if x > 3234566667:
        return
    for i in range(10):
        if abs(x % 10 - i) <= 1:
            dfs(x * 10 + i)


for i in range(1, 10):
    dfs(i)
a = sorted(a)
print((a[k - 1]))


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(eval(input()))
    res = []

    def dfs(x):
        res.append(x)
        if len(str(x)) == 10:
            return

        for i in range(10):
            if abs(x % 10 - i) <= 1:
                dfs(x * 10 + i)

        return

    for i in range(1, 10):
        dfs(i)
    res.sort()
    print((res[k - 1]))


if __name__ == '__main__':
    resolve()
# Original solution
k = int(eval(input()))

# キュー
from collections import deque

d = deque()
for i in range(1,10):
    d.append(i)

for i in range(k):
    tmp = d.popleft()
    right = tmp%10
    if(right!=0):
        d.append(tmp*10+right-1)
    d.append(tmp*10+right)
    if(right!=9):
        d.append(tmp*10+right+1)

print(tmp)

# Optimized solution
k = int(eval(input()))

def calc_dp(n):
    if(n==0):
        return 0

    s = str(n)
    slen = len(s)
    dp = [[0] * 12 for _ in range(slen)]
    dp_o = [[0] * 12 for _ in range(slen)]

    #initial
    for i in range(1,int(s[0])):
        dp[0][i+1] = 1
    dp_o[0][int(s[0])+1] = 1

    #update
    for i in range(slen-1):
        for j in range(1,11):
            dp[i+1][j] = dp[i][j-1] + dp[i][j] + dp[i][j+1] +1
        dp[i+1][1] -= 1

        s_b = int(s[i])
        s_n = int(s[i+1])

        for j in range( max(0,s_b-1), min(10, s_b+2)  ):
            if(j < s_n ):
                dp[i+1][j+1] += dp_o[i][s_b+1]
            elif(j == s_n):
                dp_o[i+1][j+1] += dp_o[i][s_b+1]

    ans = 0
    for i in range(1,11):
        ans += dp[-1][i] + dp_o[-1][i]

    return ans

min_ = 0
max_ = 3234566676


for i in range(100):
    tmp = (min_+max_)//2
    tmp_c = calc_dp(tmp)
    if(k > tmp_c):
        min_ = tmp
    else:
        max_ = tmp

    if(max_ - min_ == 1 ):
        break

print(max_)
# Original solution
ln_l = [1,2,3,4,5,6,7,8,9]

def dps(curr_num):
    end_num = curr_num[-1]
    for i in [-1,0,1]:
        added_num = int(end_num) + i
        if added_num == -1 or added_num == 10:
            continue
        curr_num_plus = curr_num + str(added_num)
        ln_l.append(int(curr_num_plus))
        if len(curr_num_plus) < 10:
            dps(curr_num_plus)

def main():
    k = int(eval(input()))
    for i in range(1,9+1):
        dps(str(i))
    ln_l.sort()
    print((ln_l[k-1]))

if __name__ == "__main__":
    main()

# Optimized solution
def dfs(lls, curr_num, lim):
    if curr_num > lim: return
    lls.append(curr_num)
    last_num = int(str(curr_num)[-1])
    if last_num > 0:
        dfs(lls, curr_num*10+last_num-1, lim)
    if last_num < 9:
        dfs(lls, curr_num*10+last_num+1, lim)
    dfs(lls, curr_num*10+last_num, lim)


def main():
    k = int(eval(input()))
    lls = []
    for i in range(1,10):
        dfs(lls, i, 3234566668)

    lls.sort()
    print((lls[k-1]))
    


if __name__ == "__main__":
    main()
# Original solution
def runrun(K,S):
    if K <= len(S):
        S.sort()
        ##print(S)
        print((S[K-1]))
        return 
    else:
        for i in range(len(S)):
            tmp = S[i]%10
            if tmp == 9:
                S.append(S[i]*10+8)
                S.append(S[i]*10+9)
            elif tmp == 0:
                S.append(S[i]*10+1)
                S.append(S[i]*10)
            else:
                S.append(S[i]*10+tmp-1)
                S.append(S[i]*10+tmp)
                S.append(S[i]*10+tmp+1)
        S = list(set(S))
        runrun(K,S)

if __name__ == "__main__":
    K = int(eval(input()))
    S = []
    for i in range(1,10):
        S.append(i)
    runrun(K,S)

# Optimized solution
def lunlun(K,S):
    if len(S) >= K:
        S.sort()
        print((S[K-1]))
        return

    for a in range(len(S)):
        i = S[a]
        rem = i%10
        n = 10*i + rem

        if rem == 9:
            S.append(n)
            S.append(n-1)
        elif rem == 0:
            S.append(n)
            S.append(n+1)
        else:
            S.append(n)
            S.append(n+1)
            S.append(n-1)
    lunlun(K,list(set(S)))


K = int(eval(input()))
S = [i for i in range(1,10)]

lunlun(K,S)
# Original solution
from collections import deque
K = int(eval(input()))

cnt = 0
q = deque()
for i in range(1, 10):
    q.append(i)
while cnt < K:
    num = q.popleft()
    cnt += 1
    if num%10 > 0:
        q.append(10*num+(num%10)-1)
    q.append(10*num+(num%10))
    if num%10 < 9:
        q.append(10*num+(num%10)+1)

print(num)

# Optimized solution
K = int(eval(input()))

def f(n, k, a):
    if k == n:
        return 1
    res = 0
    res += f(n, k+1, a)
    if a > 0:
        res += f(n, k+1, a-1)
    if a < 9:
        res += f(n, k+1, a+1)
    return res


cnt = 0
for n in range(1, 12):
    c2 = 0
    for a in range(1, 10):
        c2 += f(n, 1, a)
        if cnt+c2 >= K:
            num = n
            ini = a
            cnt += c2-f(n, 1, a)
            c2 = -1
            break
    if c2 < 0:
        break
    cnt += c2

ans = [ini]
for k in range(2, num+1):
    for a in range(max(0, ans[-1]-1), min(10, ans[-1]+2)):
        cnt += f(num, k, a)
        if cnt >= K:
            ans.append(a)
            cnt -= f(num, k, a)
            break

for i in range(len(ans)):
    ans[i] = str(ans[i])
print(("".join(ans)))
# Original solution
import sys
from collections import deque
input = sys.stdin.readline

n=int(eval(input()))
L=deque(list(range(1,10)))
if n<=9:
    ans = L[n-1]
else:
    cnt = 9
    for i in range(1,n):
        c=L.popleft()
        
        if c%10!=0:
            L.append(c*10+(c%10)-1)
            cnt+=1
            if cnt>=n:
                break
        L.append(c*10+(c%10))
        cnt+=1
        if cnt>=n:
            break
        
        if c%10!=9:
            L.append(c*10+(c%10)+1)
            cnt+=1
            if cnt>=n:
                break
    ans = L[-1]
print(ans)


# Optimized solution
import sys
from collections import deque
input = sys.stdin.readline

n=int(eval(input()))
L=deque([i for i in range(1,10)])
if n<=9:
    ans = L[n-1]
else:
    cnt = 9
    for i in range(1,n):
        c=L.popleft()
        
        if c%10!=0:
            L.append(c*10+(c%10)-1)
            cnt+=1
            if cnt>=n:
                break
        L.append(c*10+(c%10))
        cnt+=1
        if cnt>=n:
            break
        
        if c%10!=9:
            L.append(c*10+(c%10)+1)
            cnt+=1
            if cnt>=n:
                break
    ans = L[-1]
print(ans)
# Original solution
import heapq

K = int(eval(input()))

Q = [1,2,3,4,5,6,7,8,9]
heapq.heapify(Q)

for i in range(K-1):
    x = heapq.heappop(Q)
    if x % 10 != 0:
        heapq.heappush(Q,10*x+x%10-1)
    heapq.heappush(Q,10*x+x%10)
    if x % 10 != 9:
        heapq.heappush(Q,10*x+x%10+1)

print((heapq.heappop(Q)))

# Optimized solution
from collections import deque

K = int(eval(input()))

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

for i in range(K-1):
    x = Q.popleft()
    if x % 10 != 0:
        Q.append(10*x+x%10-1)
    Q.append(10*x+x%10)
    if x % 10 != 9:
        Q.append(10*x+x%10+1)

print((Q.popleft()))