# 再帰的なDFS

def rec(d, val, nums):

    nums.append(val)

    if d == 10:

        return

    

    for delta in (-1, 0, 1):

        add = val % 10 + delta

        if add >= 0 and add <= 9:

            rec(d+1, val * 10 + add, nums)



def main():

    K = int(eval(input()))

    nums = []

    for val in range(1, 10):

        rec(1, val, nums)

    nums.sort()

    print((nums[K-1]))



main()
from collections import deque

K = int(eval(input()))

que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K):

    num = que.popleft()

    if i == K-1:

        print(num)

        break

    if num%10 == 0:

        que.append(num*10 + num%10)

        que.append(num*10 + num%10 + 1)

    elif num%10 == 9:

        que.append(num*10 + num%10 - 1)

        que.append(num*10 + num%10)

    else:

        que.append(num*10 + num%10 - 1)

        que.append(num*10 + num%10)

        que.append(num*10 + num%10 + 1)

# 再帰的なDFS
def rec(d, val, nums):
    nums.append(val)
    if d == 10:
        return
    for delta in (-1, 0, 1):
        add = val % 10 + delta
        if add >= 0 and add <= 9:
            rec(d + 1, val * 10 + add, nums)


def main():
    K = int(eval(input()))
    nums = []
    for val in range(1, 10):
        rec(1, val, nums)
    nums.sort()
    print((nums[K - 1]))


main()

from collections import deque

K = int(eval(input()))
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(K):
    num = que.popleft()
    if i == K - 1:
        print(num)
        break
    if num % 10 == 0:
        que.append(num * 10 + num % 10)
        que.append(num * 10 + num % 10 + 1)
    elif num % 10 == 9:
        que.append(num * 10 + num % 10 - 1)
        que.append(num * 10 + num % 10)
    else:
        que.append(num * 10 + num % 10 - 1)
        que.append(num * 10 + num % 10)
        que.append(num * 10 + num % 10 + 1)

-# 再帰的なDFS -def rec(d, val, nums): -    nums.append(val) -    if d == 10: -        return -    for delta in (-1, 0, 1): -        add = val % 10 + delta -        if add >= 0 and add <= 9: -            rec(d + 1, val * 10 + add, nums) +from collections import deque - -def main(): -    K = int(eval(input())) -    nums = [] -    for val in range(1, 10): -        rec(1, val, nums) -    nums.sort() -    print((nums[K - 1])) - - -main() +K = int(eval(input())) +que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) +for i in range(K): +    num = que.popleft() +    if i == K - 1: +        print(num) +        break +    if num % 10 == 0: +        que.append(num * 10 + num % 10) +        que.append(num * 10 + num % 10 + 1) +    elif num % 10 == 9: +        que.append(num * 10 + num % 10 - 1) +        que.append(num * 10 + num % 10) +    else: +        que.append(num * 10 + num % 10 - 1) +        que.append(num * 10 + num % 10) +        que.append(num * 10 + num % 10 + 1)