#coding:utf-8



def up(nums):

    if len(nums) == nums.count(9):

        nums = [1] + [0] * len(nums)

        return nums

    

    for i in list(reversed(list(range(len(nums))))):

        if nums[i] > nums[i-1] or nums[i] == 9:

            continue

        else:

            nums[i] += 1

            for j in range(i+1, len(nums)):

                if j == len(nums) - 1:

                    nums[j] = max(nums[j-1]-1, 0)

                else:

                    nums[j] = max(nums[j-1] - 1, 0)

            return nums

          

  

def main():

    k = int(eval(input()))

    if k < 10:

        print(k)

        return

    cnt = 11

    nums = [1, 0]

    while cnt <= k:

        cnt += 1

        nums = up(nums)

        #print(nums)

        

    print((''.join([str(num) for num in nums])))

        

    

        

  

if __name__ == '__main__':

    main()
#coding:utf-8



def up(nums):

    if len(nums) == nums.count(9):

        nums = [1] + [0] * len(nums)

        return nums

    

    for i in list(reversed(list(range(len(nums))))):

        if nums[i] > nums[i-1] or nums[i] == 9:

            continue

        else:

            nums[i] += 1

            for j in range(i+1, len(nums)):

                nums[j] = max(nums[j-1]-1, 0)

            return nums

          

  

def main():

    k = int(eval(input()))

    nums = [0]

    for _ in range(k):

        nums = up(nums)

        

    print((''.join([str(num) for num in nums])))

        

    

        

  

if __name__ == '__main__':

    main()
# coding:utf-8
def up(nums):
    if len(nums) == nums.count(9):
        nums = [1] + [0] * len(nums)
        return nums
    for i in list(reversed(list(range(len(nums))))):
        if nums[i] > nums[i - 1] or nums[i] == 9:
            continue
        else:
            nums[i] += 1
            for j in range(i + 1, len(nums)):
                if j == len(nums) - 1:
                    nums[j] = max(nums[j - 1] - 1, 0)
                else:
                    nums[j] = max(nums[j - 1] - 1, 0)
            return nums


def main():
    k = int(eval(input()))
    if k < 10:
        print(k)
        return
    cnt = 11
    nums = [1, 0]
    while cnt <= k:
        cnt += 1
        nums = up(nums)
        # print(nums)
    print(("".join([str(num) for num in nums])))


if __name__ == "__main__":
    main()

# coding:utf-8
def up(nums):
    if len(nums) == nums.count(9):
        nums = [1] + [0] * len(nums)
        return nums
    for i in list(reversed(list(range(len(nums))))):
        if nums[i] > nums[i - 1] or nums[i] == 9:
            continue
        else:
            nums[i] += 1
            for j in range(i + 1, len(nums)):
                nums[j] = max(nums[j - 1] - 1, 0)
            return nums


def main():
    k = int(eval(input()))
    nums = [0]
    for _ in range(k):
        nums = up(nums)
    print(("".join([str(num) for num in nums])))


if __name__ == "__main__":
    main()

-                if j == len(nums) - 1: -                    nums[j] = max(nums[j - 1] - 1, 0) -                else: -                    nums[j] = max(nums[j - 1] - 1, 0) +                nums[j] = max(nums[j - 1] - 1, 0) -    if k < 10: -        print(k) -        return -    cnt = 11 -    nums = [1, 0] -    while cnt <= k: -        cnt += 1 +    nums = [0] +    for _ in range(k): -        # print(nums)