import sys

k=int(eval(input()))

ans=[""]

for i in range(1,13):

    ans.append(i)

for i in range(1,8):

    a=10*(i+1)+(i)

    for j in range(3):

        ans.append(a)

        a+=1

ans.append(98)

ans.append(99)

#print(ans)

#print(len(ans))

if k<=35:

    print((ans[k]))

else:

    def search(i,j):

        total=0

        if i==1:

            #print(j)

            return 1

        for m in range(10):

            if abs(j-m)<=1:

                total+=search(i-1,m)

        return total

    def search2(i,j,anss):

        global plus,aaa

        if i==1:

            plus+=1

            #print(kind)

            #print(anss)

            #print(aaa+plus)

            if k==aaa+plus:

                #print(aaa+plus)

                print(anss)

            return 

        for m in range(10):

            if abs(j-m)<=1:

                search2(i-1,m,anss+str(m))

    num=[35] #各桁の種類(累計

    for i in range(3,11): #桁数

        for j in range(1,10): #先頭の数字

            count=search(i,j)

            num.append(num[-1]+count)

    #print(num)

    ab=0

    while num[ab]<k:

        ab+=1

    #print(ab)

    rank=ab//9

    sento=ab%9

    if sento==0:

        sento=9

    #where=sento*(10**(2+rank))

    #print(where)

    aaa=num[ab-1]

    plus=0

    search2(3+rank,sento,str(sento))
k=int(eval(input()))

total=0

def count(keta,s,ans):

    global total

    if keta==1:

        total+=1

        if k==total:

            print(ans) #ここで終了させたい

        return 

    for m in range(10):

        if abs(s-m)<=1:

            count(keta-1,m,ans+str(m))

for i in range(1,11):

    for j in range(1,10):

        count(i,j,str(j))
import sys

k = int(eval(input()))
ans = [""]
for i in range(1, 13):
    ans.append(i)
for i in range(1, 8):
    a = 10 * (i + 1) + (i)
    for j in range(3):
        ans.append(a)
        a += 1
ans.append(98)
ans.append(99)
# print(ans)
# print(len(ans))
if k <= 35:
    print((ans[k]))
else:

    def search(i, j):
        total = 0
        if i == 1:
            # print(j)
            return 1
        for m in range(10):
            if abs(j - m) <= 1:
                total += search(i - 1, m)
        return total

    def search2(i, j, anss):
        global plus, aaa
        if i == 1:
            plus += 1
            # print(kind)
            # print(anss)
            # print(aaa+plus)
            if k == aaa + plus:
                # print(aaa+plus)
                print(anss)
            return
        for m in range(10):
            if abs(j - m) <= 1:
                search2(i - 1, m, anss + str(m))

    num = [35]  # 各桁の種類(累計
    for i in range(3, 11):  # 桁数
        for j in range(1, 10):  # 先頭の数字
            count = search(i, j)
            num.append(num[-1] + count)
    # print(num)
    ab = 0
    while num[ab] < k:
        ab += 1
    # print(ab)
    rank = ab // 9
    sento = ab % 9
    if sento == 0:
        sento = 9
    # where=sento*(10**(2+rank))
    # print(where)
    aaa = num[ab - 1]
    plus = 0
    search2(3 + rank, sento, str(sento))

k = int(eval(input()))
total = 0


def count(keta, s, ans):
    global total
    if keta == 1:
        total += 1
        if k == total:
            print(ans)  # ここで終了させたい
        return
    for m in range(10):
        if abs(s - m) <= 1:
            count(keta - 1, m, ans + str(m))


for i in range(1, 11):
    for j in range(1, 10):
        count(i, j, str(j))

-import sys +k = int(eval(input())) +total = 0 -k = int(eval(input())) -ans = [""] -for i in range(1, 13): -    ans.append(i) -for i in range(1, 8): -    a = 10 * (i + 1) + (i) -    for j in range(3): -        ans.append(a) -        a += 1 -ans.append(98) -ans.append(99) -# print(ans) -# print(len(ans)) -if k <= 35: -    print((ans[k])) -else: -    def search(i, j): -        total = 0 -        if i == 1: -            # print(j) -            return 1 -        for m in range(10): -            if abs(j - m) <= 1: -                total += search(i - 1, m) -        return total +def count(keta, s, ans): +    global total +    if keta == 1: +        total += 1 +        if k == total: +            print(ans)  # ここで終了させたい +        return +    for m in range(10): +        if abs(s - m) <= 1: +            count(keta - 1, m, ans + str(m)) -    def search2(i, j, anss): -        global plus, aaa -        if i == 1: -            plus += 1 -            # print(kind) -            # print(anss) -            # print(aaa+plus) -            if k == aaa + plus: -                # print(aaa+plus) -                print(anss) -            return -        for m in range(10): -            if abs(j - m) <= 1: -                search2(i - 1, m, anss + str(m)) -    num = [35]  # 各桁の種類(累計 -    for i in range(3, 11):  # 桁数 -        for j in range(1, 10):  # 先頭の数字 -            count = search(i, j) -            num.append(num[-1] + count) -    # print(num) -    ab = 0 -    while num[ab] < k: -        ab += 1 -    # print(ab) -    rank = ab // 9 -    sento = ab % 9 -    if sento == 0: -        sento = 9 -    # where=sento*(10**(2+rank)) -    # print(where) -    aaa = num[ab - 1] -    plus = 0 -    search2(3 + rank, sento, str(sento)) +for i in range(1, 11): +    for j in range(1, 10): +        count(i, j, str(j))