k = int(input())
a = [[0,1], [0,1,2], [1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9]]

b = 9  #個目まで生成済み
runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9] + [0]*150000
hk = 1
keta = 2

def hi(hitoketamae):
    pass

'''
if k<=9:
    print(k)
else:
'''
while b<k:
    """
    if keta == 11:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            for i6 in a[i5]:
                                for i7 in a[i6]:
                                    for i8 in a[i7]:
                                        for i9 in a[i8]:
                                            for i10 in a[i9]:
                                                b += 1
                                                runrun[b] = [hk, i1, i2, i3, i4, i5, i6, i7, i8, i9]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    """
    if keta == 10:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            for i6 in a[i5]:
                                for i7 in a[i6]:
                                    for i8 in a[i7]:
                                        for i9 in a[i8]:
                                            b += 1
                                            runrun[b] = [hk, i1, i2, i3, i4, i5, i6, i7, i8, i9]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 9:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            for i6 in a[i5]:
                                for i7 in a[i6]:
                                    for i8 in a[i7]:
                                        b += 1
                                        runrun[b] = [hk, i1, i2, i3, i4, i5, i6, i7, i8]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 8:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            for i6 in a[i5]:
                                for i7 in a[i6]:
                                    b += 1
                                    runrun[b] = [hk, i1, i2, i3, i4, i5, i6, i7]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 7:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            for i6 in a[i5]:
                                b += 1
                                runrun[b] = [hk, i1, i2, i3, i4, i5, i6]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 6:
        for i1 in a[hk]:
            for i2 in a[i1]:
                for i3 in a[i2]:
                    for i4 in a[i3]:
                        for i5 in a[i4]:
                            b += 1
                            runrun[b] = [hk, i1, i2, i3, i4, i5]
        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 5:
        for i in a[hk]:
            for j in a[i]:
                for jj in a[j]:
                    for jjj in a[jj]:
                            b += 1
                            runrun[b] = [hk, i, j, jj, jjj]

        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 4:
        for i in a[hk]:
            for j in a[i]:
                for jj in a[j]:
                    b += 1
                    runrun[b] = [hk, i, j, jj]

        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    if keta == 3:
        for i in a[hk]:
            for j in a[i]:
                b += 1
                #runrun[b] = hk * (10 ** (keta-1)) + i * (10 ** (keta-2)) + j
                runrun[b] = [hk, i, j]

        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
    elif keta == 2:
        for i in a[hk]:
            b += 1
            runrun[b] = [hk, i]

        if hk!=9:
            hk += 1
        else:
            hk = 1
            keta = keta + 1
        
ans = ''


if k<=9:
    ans = int(k)
else:
    for i in runrun[k]:
        ans = ans + str(i)
    ans = int(ans)
print(ans)

Measured memory_bytes: 20568