n = int(input())
listnum = [[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]]
listans = []
for i in range(1, 10):
    numb = str(i)
    listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        numb = str(i) + str(j)
        listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            numb = str(i) + str(j) + str(m)
            listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                numb = str(i) + str(j) + str(m) + str(x)
                listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    numb = str(i) + str(j) + str(m) + str(x) + str(x2)
                    listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    for x3 in listnum[x2]:
                        numb = str(i) + str(j) + str(m) + str(x) + str(x2) + str(x3)
                        listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    for x3 in listnum[x2]:
                        for x4 in listnum[x3]:
                            numb = str(i) + str(j) + str(m) + str(x) + str(x2) + str(x3) + str(x4)
                            listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    for x3 in listnum[x2]:
                        for x4 in listnum[x3]:
                            for x5 in listnum[x4]:
                                numb = str(i) + str(j) + str(m) + str(x) + str(x2) + str(x3) + str(x4) + str(x5)
                                listans.append(int(numb))
for i in range(1, 10):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    for x3 in listnum[x2]:
                        for x4 in listnum[x3]:
                            for x5 in listnum[x4]:
                                for x6 in listnum[x5]:
                                    numb = str(i) + str(j) + str(m) + str(x) + str(x2) + str(x3) + str(x4) + str(x5) + str(x6)
                                    listans.append(int(numb))
for i in range(1, 5):
    for j in listnum[i]:
        for m in listnum[j]:
            for x in listnum[m]:
                for x2 in listnum[x]:
                    for x3 in listnum[x2]:
                        for x4 in listnum[x3]:
                            for x5 in listnum[x4]:
                                for x6 in listnum[x5]:
                                    for x7 in listnum[x6]:
                                        numb = str(i) + str(j) + str(m) + str(x) + str(x2) + str(x3) + str(x4) + str(x5) + str(x6) + str(x7)
                                        listans.append(int(numb))
print(listans[n - 1])

Measured memory_bytes: 59096