CodeEff/ECCO huggingface dataset:
# Original solution
from collections import deque
K = int(eval(input()))

Queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(K):
    x = Queue[0]
    Queue.popleft()
    oneplace = x % 10

    #(1の位の数)-1を付け加えた数を入れる
    if oneplace == 0: #xの1の位が0
        pass
    else:   #xの1の位が0でない
        enqueue = x * 10 + (oneplace - 1)
        Queue.append(enqueue)
    
    #1の位の数を付け加えた数を入れる
    enqueue = x * 10 + oneplace
    Queue.append(enqueue)

    #(1の位の数)+1を付け加えた数を入れる
    if oneplace == 9:   #xの1の位の数が9
        pass
    else:
        enqueue = x * 10 + (oneplace + 1)
        Queue.append(enqueue)

print(x)

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

B = [1, 2, 3, 4, 5, 6, 7, 8, 9] #Before list
while len(B) < k:
    k -= len(B)
    #次の桁に更新
    def update_next_digit(B:list)->list:
        N = []  #New list
        for i in range(len(B)):
            op = B[i] % 10  #one place   
            for j in [-1, 0, 1]:
                if 0 <= op+j and op+j <= 9:
                    N.append(B[i]*10+(op+j))
                else:
                    pass
        return N
    N = update_next_digit(B)
    B = N

ans = B[k-1]
print(ans)
# Original solution
K = int(input())

N = [0]

for _ in range(K):
    i = 0
    while i < len(N) and N[i] == 9:
        i += 1
    while i+1 < len(N) and N[i] == N[i+1]+1:
        i += 1
    if i == len(N):
        N = [0]*len(N) + [1]
    else:
        N[i] += 1
        i -= 1
        while i >= 0:
            N[i] = max(N[i+1]-1,0)
            i -= 1

print(*reversed(N),sep='')


# Optimized solution
from collections import deque

K = int(eval(input()))

q = deque(list(range(1,10)))

for _ in range(K):
    x = q.popleft()
    r = x%10
    if r == 0:
        q.append(x*10)
        q.append(x*10+1)
    elif r == 9:
        q.append(x*10+8)
        q.append(x*10+9)

    else:
        q.append(x*10+r-1)
        q.append(x*10+r)
        q.append(x*10+r+1)
print(x)
# Original solution
import copy
K = int(eval(input()))
ans, nex = [i for i in range(1, 10)], [i for i in range(1, 10)]
for i in range(10):
    pre, nex = copy.deepcopy(nex), []
    for p in pre:
        if p % 10 != 0:
            ans.append(p * 10 + p % 10 - 1)
            nex.append(p * 10 + p % 10 - 1)
        ans.append(p * 10 + p % 10)
        nex.append(p * 10 + p % 10)
        if p % 10 != 9:
            ans.append(p * 10 + p % 10 + 1)
            nex.append(p * 10 + p % 10 + 1)

ans.sort()
print((ans[K - 1]))


# Optimized solution
from collections import deque
d = deque([9, 8, 7, 6, 5, 4, 3, 2, 1])

K = int(eval(input()))
for _ in range(K - 1):
    i = d.pop()
    if i % 10 != 0:
        d.appendleft(i * 10 + i % 10 - 1)
    d.appendleft(i * 10 + i % 10)
    if i % 10 != 9:
        d.appendleft(i * 10 + i % 10 + 1)
print((d.pop()))
# Original solution
def pat(K,count,keta,num):
    #print(str(num)+":"+str(count)+":"+str(keta))
    if count == -1:
        return -1
    elif keta == 1:
        if count == K-1:
            print(num)
            return count + 1
        else:
            return (count+1)

    else:
        if (int(num[-1])) -1 >= 0:
            count = pat(K,count,keta-1,num+str(int(num[-1])-1))
        count = pat(K,count,keta-1,num+num[-1])
        if (int(num[-1])+1) <= 9:
            count = pat(K,count,keta-1,num+str(int(num[-1])+1))
    if count >=K:
        return -1
    else:
        return count
K = int(eval(input()))
count = 0
ans = list()
keta = 0

while True:
    keta += 1
    for i in range(1,10):
        count = pat(K,count,keta,str(i))
        #print(count)
        if count  == -1:
            break
    if count == -1:
        break
        



# Optimized solution
def pat(K,count,keta,num):
    #print(str(num)+":"+str(count)+":"+str(keta))
    if count == -1:
        return -1
    elif keta == 1:
        if count == K-1:
            print(num)
            return -1
        else:
            return (count+1)
    else:
        if (int(num[-1])) -1 >= 0:
            count = pat(K,count,keta-1,num+str(int(num[-1])-1))
        count = pat(K,count,keta-1,num+num[-1])
        if (int(num[-1])+1) <= 9:
            count = pat(K,count,keta-1,num+str(int(num[-1])+1))
            
    return count


K = int(eval(input()))
count = 0
ans = list()
keta = 0

while True:
    keta += 1
    for i in range(1,10):
        count = pat(K,count,keta,str(i))
        #print(count)
        if count  == -1:
            break
    if count == -1:
        break
# Original solution
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    K = int(eval(input()))
    ans = list("123456789")
    tmp = ans.copy()
    while True:
        tmp2 = []
        for t in tmp:
            for i in range(int(t[-1]) - 1, int(t[-1]) + 2):
                if 0 <= i < 10:
                    tmp2.append(t + str(i))
        tmp = tmp2.copy()
        ans += tmp
        if len(ans) >= K:
            break

    print((ans[K - 1]))


if __name__ == "__main__":
    main()


# Optimized solution
import collections
import sys


def input():
    return sys.stdin.readline().strip()


def bfs(K):
    q = collections.deque(list("123456789"))
    ans = list("123456789")
    while len(ans) < K:
        n = q.popleft()
        for i in range(int(n[-1]) - 1, int(n[-1]) + 2):
            if 0 <= i < 10:
                q.append(n + str(i))
                ans.append(n + str(i))

    return ans[K - 1]


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


if __name__ == "__main__":
    main()
# Original solution
from collections import deque
k = int(eval(input()))
lunlun = deque([i for i in range(9, 0, -1)])
for i in range(k):
    x = lunlun.pop()
    if i == k - 1:
        print(x)
    next_lunlun = 10*x + (x % 10)
    if x % 10 != 0:
        lunlun.appendleft(next_lunlun - 1)
    lunlun.appendleft(next_lunlun)
    if x % 10 != 9:
        lunlun.appendleft(next_lunlun + 1)

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

def is_lunlun(i):
    result = -1
    n = [ord(c) -48 for c in str(i)]
    for j in range(len(n) - 1):
        if abs(n[j] - n[j + 1]) <= 1:
            continue
        if n[j] < n[j + 1]:
            for k in range(j + 1, len(n)):
                n[k] = 0
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 1))
        else:
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 2))
        break
    return result

i = 1
while True:
    #print(i)
    t = is_lunlun(i)
    if t == -1:
        K -= 1
        if K == 0:
            print(i)
            exit()
        i += 1
    else:
        i = t


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


def is_lunlun(i):
    result = -1
    n = [ord(c) - 48 for c in str(i)]
    for j in range(len(n) - 1):
        if abs(n[j] - n[j + 1]) <= 1:
            continue
        if n[j] < n[j + 1]:
            for k in range(j + 1, len(n)):
                n[k] = max(n[k - 1] - 1, 0)
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 1))
        else:
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 2))
        break
    return result


i = 1
while True:
    # print(i)
    t = is_lunlun(i)
    if t == -1:
        K -= 1
        if K == 0:
            print(i)
            exit()
        i += 1
    else:
        i = t
# Original solution
K = int(eval(input()))
A = [1,2,3,4,5,6,7,8,9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1,2):
            a = int(str(A[i]) + str(A[i]+j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = len(A.copy())
for i in range(10, L1):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L2 = len(A.copy())
for i in range(8):
    for i in range(L1,L2):
        B = A[i]
        if B % 10 == 0:
            A.append(int(str(B) + '0'))
            A.append(int(str(B) + '1'))
        elif B % 10 == 9:
            A.append(int(str(B) + '8'))
            A.append(int(str(B) + '9'))
        else:
            for j in range(-1, 2):
                a = int(str(B) + str((B % 10) + j))
                A.append(a)
    L1 = L2
    L2 = len(A.copy())
print((A[K-1]))

# Optimized solution
K = int(eval(input()))
A = [1,2,3,4,5,6,7,8,9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1,2):
            a = int(str(A[i]) + str(A[i]+j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = 10
L2 = len(A.copy())
for i in range(8):
    for i in range(L1,L2):
        B = A[i]
        if B % 10 == 0:
            A.append(int(str(B) + '0'))
            A.append(int(str(B) + '1'))
        elif B % 10 == 9:
            A.append(int(str(B) + '8'))
            A.append(int(str(B) + '9'))
        else:
            for j in range(-1, 2):
                a = int(str(B) + str((B % 10) + j))
                A.append(a)
    L1 = L2
    L2 = len(A.copy())
print((A[K-1]))
# Original solution
from queue import Queue

k = int(eval(input()))

q = Queue()
for i in range(1, 10):
    q.put(i)

for _ in range(k):
    x = q.get()
    if x % 10 != 0:
        q.put(x*10 + x%10 - 1)
    q.put(x*10 + x%10)
    if x % 10 != 9:
        q.put(x*10 + x%10 + 1)

print(x)


# Optimized solution
from collections import deque

k = int(eval(input()))

q = deque(list(range(1, 10)))
for _ in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(x*10 + x%10 - 1)
    q.append(x*10 + x%10)
    if x % 10 != 9:
        q.append(x*10 + x%10 + 1)

print(x)
# Original solution
# Problem D - Lunlun Number

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

# initialization
num_queue = []
k = 1

# count
while True:
    if k>=1 and k<=9: # 1桁の場合
        num_queue.append(k)
        k += 1
    else: # 2桁以降の場合
        min_num = str(num_queue.pop(0))
        keta_1 = int(min_num[-1])
        if keta_1==0:
            for i in range(2):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
        elif keta_1==9:
            for i in range(keta_1-1, keta_1+1):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
        else:
            for i in range(keta_1-1, keta_1+2):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
    if k>K:
        break

# output
print((num_queue[-1]))


# Optimized solution
# Problem D - Lunlun Number

from collections import deque

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

# initialization
num_queue = deque()
k = 1

# count
while True:
    if k>=1 and k<=9:
        num_queue.append(k)
        k += 1
    else:
        num = str(num_queue.popleft())
        num_str = int(num[-1])
        if num_str==0:
            for i in range(2):
                tmp = str(i)
                num_queue.append(int(num + tmp))
                k += 1
                if k-1==K:
                    break
        elif num_str==9:
            for i in range(8,10):
                tmp = str(i)
                num_queue.append(int(num + tmp))
                k += 1
                if k-1==K:
                    break
        else:
            for i in range(num_str-1, num_str+2):
                tmp = str(i)
                num_queue.append(int(num + tmp))
                k += 1
                if k-1==K:
                    break

    if k-1==K:
        break

# output
print((num_queue[-1]))
# Original solution
def dfs(d, r):
    global l
    if d == 11:
        return
    l.append(int(r))
    for i in range(-1, 2):
        tmp = int(r[-1]) + i
        if 0 <= tmp <= 9:
            dfs(d + 1, r + str(tmp))


k = int(eval(input()))
l = []
for i in range(1, 10):
    dfs(0, str(i))
print((sorted(l)[k - 1]))

# Optimized solution
def dfs(d, r):
    global l
    if d == 11:
        return
    l.append(int(r))
    for i in range(-1, 2):
        tmp = int(r[-1]) + i
        if 0 <= tmp <= 9:
            dfs(d + 1, r + str(tmp))


k = int(eval(input()))
l = []
for i in range(1, 10):
    dfs(1, str(i))
print((sorted(l)[k - 1]))
# Original solution
K = int(eval(input()))

lunlun_number_list = []

def dfs(N):
    lunlun_number_list.append(N)
    if len(str(N)) > 10:
        return
    now_int = int(str(N)[-1])
    if now_int == 0:
        for i in range(2):
            dfs(N*10 + i)
    elif now_int == 9:
        for i in range(8, 10, 1):
            dfs(N*10 + i)
    else:
        for i in range(now_int-1, now_int+2, 1):
            dfs(N*10 + i)

for i in range(1, 10, 1):
    dfs(i)

lunlun_number_list.sort()
print((lunlun_number_list[K-1]))


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

que = collections.deque()
for i in range(1, 10, 1):
    que.append(i)
cnt = 0
for i in range(K):
    x = que.popleft()
    cnt += 1
    if cnt == K:
        print(x)
        exit()
    if x%10 == 0:
        que.append(10*x+0)
        que.append(10*x+1)
    elif x%10 == 9:
        que.append(10*x+8)
        que.append(10*x+9)
    else:
        que.append(10*x+(x%10)-1)
        que.append(10*x+(x%10)+0)
        que.append(10*x+(x%10)+1)
# Original solution
import os
import sys

from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def is_ok(n):
    s = str(n)
    ok = True
    for a, b in zip(s, s[1:]):
        if not abs(int(a) - int(b)) <= 1:
            return False
    return True


@lru_cache(maxsize=None)
def rekkyo(n, d):
    if d == 0:
        return ['']
    ret = []
    if n > 0:
        for s in rekkyo(n - 1, d - 1):
            ret.append(str(n - 1) + s)
    for s in rekkyo(n, d - 1):
        ret.append(str(n) + s)
    if n < 9:
        for s in rekkyo(n + 1, d - 1):
            ret.append(str(n + 1) + s)
    return ret


K = int(sys.stdin.buffer.readline())

s = set()
for i in range(10):
    for j in range(1,11):
        a = rekkyo(i, j)
        s |= set(a)
a = list(sorted(set(list(map(int, s)))))
print((a[K]))
# for aa in a:
#     print(aa)


# Optimized solution
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

# 解説
K = int(sys.stdin.buffer.readline())
que = deque(list(map(str, list(range(1, 10)))))
for _ in range(K - 1):
    # print(que)
    s = que.popleft()
    d = int(s[-1])
    if d > 0:
        que.append(s + str(d - 1))
    que.append(s + str(d))
    if d < 9:
        que.append(s + str(d + 1))
print((int(que[0])))
# Original solution
K=int(eval(input()))
A=[1,2,3,4,5,6,7,8,9]+[0]*10*K
i=9
j=0
while i<K:
    if A[j]%10!=0 and A[j]%10!=9:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    elif A[j]%10==0:
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    else:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
    j+=1
print((A[K-1]))


# Optimized solution
K=int(eval(input()))
A=[1,2,3,4,5,6,7,8,9]+[0]*K
i=9
j=0
while i<K:
    if A[j]%10!=0 and A[j]%10!=9:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    elif A[j]%10==0:
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    else:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
    j+=1
print((A[K-1]))
# Original solution
from heapq import heappop, heappush, heapify
K = int(eval(input()))
M = K

que = list(range(1, 10))
V = set()
heapify(que)

while M + 100 >= 0:
    top = heappop(que)
    if top in V:
        continue
    V.add(top)
    M -= 1

    top = str(top)
    L = int(top[0])
    R = int(top[-1])

    for i in (L - 1, L, L + 1):
        if 1 <= i <= 9:
            heappush(que, int(str(i) + top))
    for i in (R - 1, R, R + 1):
        if 0 <= i <= 9:
            heappush(que, int(top + str(i)))

V = [int(d) for d in V]
V.sort()
print((V[K - 1]))


# Optimized solution
from collections import deque
K = int(eval(input()))

que = deque(list(map(str, list(range(1, 10)))))
while K > 1:
    n = que.popleft()
    K -= 1
    R = int(n[-1])
    for r in (R - 1, R, R + 1):
        if 0 <= r <= 9:
            que.append(n + str(r))

print((que[0]))
# Original solution
from collections import deque
K = int(eval(input()))

que = deque(list(map(str, list(range(1, 10)))))
while K > 1:
    n = que.popleft()
    K -= 1
    R = int(n[-1])
    for r in (R - 1, R, R + 1):
        if 0 <= r <= 9:
            que.append(n + str(r))

print((que[0]))


# Optimized solution
from collections import deque

K = int(eval(input()))

que = deque([i for i in range(1, 10)])
ans = []
while len(ans) <= K + 10:
    now = que.popleft()
    ans.append(now)

    b = now % 10
    for i in range(max(0, b - 1), min(10, b + 2)):
        que.append(now * 10 + i)

ans.sort()
print((ans[K - 1]))
# Original solution
from collections import deque
k=int(eval(input()))
num=[]

def dfs(lun):
  #print(lun)
  num.append(lun)
  if lun>3234566667:
    return
  now=lun%10
  for i in [-1,0,1]:
    if 0<=now+i<=9:
      dfs(lun*10+now+i)

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


# Optimized solution
from collections import deque
k=int(eval(input()))
d=deque([1,2,3,4,5,6,7,8,9])
num=[1,2,3,4,5,6,7,8,9]
while d:
  now=d.popleft()
  hitoketa=now%10
  for i in [-1,0,1]:
    if 0<=hitoketa+i<=9:
      nxt=now*10+hitoketa+i
      if nxt<=3234566667:
        #print(nxt)
        num.append(nxt)
        d.append(nxt)
num.sort()
print((num[k-1]))
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
K = int(eval(input()))
RUN = {
    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]
}
cnt = 0

def dfs(i, s, p, cnt):
    if i == 0:
        if s == 0:
            return cnt        
        cnt += 1
        if cnt == K:
            print(s)
            exit()
        else:
            return cnt
    if s == 0:
        for ii in range(10):
            cnt = dfs(i-1, s+ii*10**(i-1), ii, cnt)
    else:
        for ii in RUN[p]:
            cnt = dfs(i-1, s+ii*10**(i-1), ii, cnt)

    return cnt

dfs(10, 0, 0, cnt)

# Optimized solution
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
K = int(eval(input()))
RUN = {
    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]
}
cnt = -1

def dfs(i, s, p, cnt):
    if i == 0:
        cnt += 1
        if cnt == K:
            print(s)
            exit()
        else:
            return cnt
    if s == 0:
        for ii in range(10):
            cnt = dfs(i-1, s+ii*10**(i-1), ii, cnt)
    else:
        for ii in RUN[p]:
            cnt = dfs(i-1, s+ii*10**(i-1), ii, cnt)

    return cnt

dfs(10, 0, 0, cnt)
# Original solution
n=int(eval(input()))

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

if n <= 9:
    print(n)
else:
    count = 9
    while count<=n:
        i = query.pop(0)

        if i%10-1>=0:
            query.append(i*10+(i%10-1))
            count += 1
            if count == n:
                print((i*10+(i%10-1)))
                break

        query.append(i*10+(i%10))
        count += 1
        if count == n:
            print((i*10+(i%10)))
            break

        if i%10+1<=9:
            query.append(i*10+(i%10+1))
            count += 1
            if count == n:
                print((i*10+(i%10+1)))
                break

# Optimized solution
from collections import deque

n=int(eval(input()))

if n < 10:
    print(n)
else:
    check_box = deque([1,2,3,4,5,6,7,8,9])
    check_num = 9
    while True:
        add_num = check_box.popleft()
        add_num = str(add_num)

        if int(add_num[-1]) - 1 >= 0:
            check_box.append(int(add_num + str(int(add_num[-1]) - 1)))
            check_num += 1
            if check_num == n:
                    print((add_num + str(int(add_num[-1]) - 1)))
                    exit()

        check_num += 1
        check_box.append(int(add_num + add_num[-1]))
        if check_num == n:
                print((add_num + add_num[-1]))
                exit()

        if int(add_num[-1]) + 1 <= 9:
            check_box.append(int(add_num + str(int(add_num[-1]) + 1)))
            check_num += 1
            if check_num == n:
                    print((add_num + str(int(add_num[-1]) + 1)))
                    exit()
# Original solution
from collections import deque


def main():
    k = int(eval(input()))
    if k <= 9:
        print(k)
    else:
        queue = deque()
        for i in range(1, 10):
            queue.append(i)
        flag = 1
        cnt_lunlun = 9
        while flag:
            first_element = queue.popleft()
            lunlun_nums = extend_lunlun(first_element)
            for n in lunlun_nums:
                queue.append(n)
                cnt_lunlun += 1
                if cnt_lunlun == k:
                    flag -= 1
                    break
        print((queue.pop()))


def extend_lunlun(num):
    last_digit = int(str(num)[-1])
    if last_digit == 0:
        return int(str(num)+"0"), int(str(num)+"1")
    elif last_digit == 9:
        return int(str(num) + "8"), int(str(num) + "9")
    else:
        return (
            int(str(num) + str(last_digit - 1)),
            int(str(num) + str(last_digit)),
            int(str(num) + str(last_digit + 1))
        )


if __name__ == "__main__":
    main()

# Optimized solution
from collections import deque


def main():
    k = int(eval(input()))
    if k <= 9:
        print(k)
    else:
        queue = deque()
        for i in range(1, 10):
            queue.append(i)
        flag = 1
        cnt_lunlun = 9
        while flag:
            first_element = queue.popleft()
            lunlun_nums = extend_lunlun(first_element)
            for n in lunlun_nums:
                queue.append(n)
                cnt_lunlun += 1
                if cnt_lunlun == k:
                    flag -= 1
                    break
        print((queue.pop()))


def extend_lunlun(num):
    lunlun_nums = []
    last_digit = num % 10
    for i in range(-1, 2):
        d = last_digit + i
        if d >= 0 and d <= 9:
            lunlun_nums.append(num*10+d)
    return lunlun_nums


if __name__ == "__main__":
    main()