from sys import stdin

import heapq

def main():



    input = stdin.readline



    K = int(eval(input()))



    h = []

    

    for i in range(1,10):

        heapq.heappush(h,i)

    

    for i in range(K):

        ans = heapq.heappop(h)



        if ans % 10 != 0:

            heapq.heappush(h,ans * 10 + (ans % 10 - 1))

        heapq.heappush(h,ans*10 + (ans%10))

        if ans % 10 != 9:

            heapq.heappush(h,ans * 10 + (ans % 10 + 1))

    

    print(ans)



if __name__ == "__main__":

    main()
from sys import stdin

import heapq

def main():



    input = stdin.readline



    K = int(eval(input()))



    h = []



    for i in range(1,10):

        h.append(i)

    

    for i in range(K):

        ans = h[i]



        if ans % 10 != 0:

            h.append(ans * 10 + (ans % 10 - 1))

        h.append(ans*10 + (ans%10))

        if ans % 10 != 9:

            h.append(ans * 10 + (ans % 10 + 1))

    

    print(ans)



    # for i in range(1,10):

    #     heapq.heappush(h,i)

    

    # for i in range(K):

    #     ans = heapq.heappop(h)



    #     if ans % 10 != 0:

    #         heapq.heappush(h,ans * 10 + (ans % 10 - 1))

    #     heapq.heappush(h,ans*10 + (ans%10))

    #     if ans % 10 != 9:

    #         heapq.heappush(h,ans * 10 + (ans % 10 + 1))

    

    # print(ans)



if __name__ == "__main__":

    main()
from sys import stdin
import heapq


def main():
    input = stdin.readline
    K = int(eval(input()))
    h = []
    for i in range(1, 10):
        heapq.heappush(h, i)
    for i in range(K):
        ans = heapq.heappop(h)
        if ans % 10 != 0:
            heapq.heappush(h, ans * 10 + (ans % 10 - 1))
        heapq.heappush(h, ans * 10 + (ans % 10))
        if ans % 10 != 9:
            heapq.heappush(h, ans * 10 + (ans % 10 + 1))
    print(ans)


if __name__ == "__main__":
    main()

from sys import stdin
import heapq


def main():
    input = stdin.readline
    K = int(eval(input()))
    h = []
    for i in range(1, 10):
        h.append(i)
    for i in range(K):
        ans = h[i]
        if ans % 10 != 0:
            h.append(ans * 10 + (ans % 10 - 1))
        h.append(ans * 10 + (ans % 10))
        if ans % 10 != 9:
            h.append(ans * 10 + (ans % 10 + 1))
    print(ans)
    # for i in range(1,10):
    #     heapq.heappush(h,i)
    # for i in range(K):
    #     ans = heapq.heappop(h)
    #     if ans % 10 != 0:
    #         heapq.heappush(h,ans * 10 + (ans % 10 - 1))
    #     heapq.heappush(h,ans*10 + (ans%10))
    #     if ans % 10 != 9:
    #         heapq.heappush(h,ans * 10 + (ans % 10 + 1))
    # print(ans)


if __name__ == "__main__":
    main()

-        heapq.heappush(h, i) +        h.append(i) -        ans = heapq.heappop(h) +        ans = h[i] -            heapq.heappush(h, ans * 10 + (ans % 10 - 1)) -        heapq.heappush(h, ans * 10 + (ans % 10)) +            h.append(ans * 10 + (ans % 10 - 1)) +        h.append(ans * 10 + (ans % 10)) -            heapq.heappush(h, ans * 10 + (ans % 10 + 1)) +            h.append(ans * 10 + (ans % 10 + 1)) +    # for i in range(1,10): +    #     heapq.heappush(h,i) +    # for i in range(K): +    #     ans = heapq.heappop(h) +    #     if ans % 10 != 0: +    #         heapq.heappush(h,ans * 10 + (ans % 10 - 1)) +    #     heapq.heappush(h,ans*10 + (ans%10)) +    #     if ans % 10 != 9: +    #         heapq.heappush(h,ans * 10 + (ans % 10 + 1)) +    # print(ans)