import sys

from collections import deque



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



K = ir()

A = deque([x for x in range(1, 10)])

count = 0

while True:

    cur = A.popleft()

    count += 1

    if count == K:

        answer = cur

        break

    next = 10 * cur + (cur % 10)

    if cur % 10 != 0:

        A.append(next-1)

    A.append(next)

    if cur % 10 != 9:

        A.append(next+1)



print(answer)

# coding: utf-8

import sys

sys.setrecursionlimit(10 ** 7)



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



K = ir()

num = -1



def dfs(A, i, bl):

    global num

    if i == 11:

        num += 1

        if num == K:

            ans = ''.join(map(str, A))

            ans = int(ans)

            print(ans)

            exit()

        return

    last = A[-1]

    if bl:

        dfs([0], i+1, True)

        for j in range(1, 10):

            dfs([j], i+1, False)

    else:

        if last > 0:

            dfs(A+[last-1], i+1, False)

        dfs(A+[last], i+1, False)

        if last < 9:

            dfs(A+[last+1], i+1, False)



dfs([0], 0, True)

import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
A = deque([x for x in range(1, 10)])
count = 0
while True:
    cur = A.popleft()
    count += 1
    if count == K:
        answer = cur
        break
    next = 10 * cur + (cur % 10)
    if cur % 10 != 0:
        A.append(next - 1)
    A.append(next)
    if cur % 10 != 9:
        A.append(next + 1)
print(answer)

# coding: utf-8
import sys

sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
num = -1


def dfs(A, i, bl):
    global num
    if i == 11:
        num += 1
        if num == K:
            ans = "".join(map(str, A))
            ans = int(ans)
            print(ans)
            exit()
        return
    last = A[-1]
    if bl:
        dfs([0], i + 1, True)
        for j in range(1, 10):
            dfs([j], i + 1, False)
    else:
        if last > 0:
            dfs(A + [last - 1], i + 1, False)
        dfs(A + [last], i + 1, False)
        if last < 9:
            dfs(A + [last + 1], i + 1, False)


dfs([0], 0, True)

+# coding: utf-8 -from collections import deque +sys.setrecursionlimit(10**7) -A = deque([x for x in range(1, 10)]) -count = 0 -while True: -    cur = A.popleft() -    count += 1 -    if count == K: -        answer = cur -        break -    next = 10 * cur + (cur % 10) -    if cur % 10 != 0: -        A.append(next - 1) -    A.append(next) -    if cur % 10 != 9: -        A.append(next + 1) -print(answer) +num = -1 + + +def dfs(A, i, bl): +    global num +    if i == 11: +        num += 1 +        if num == K: +            ans = "".join(map(str, A)) +            ans = int(ans) +            print(ans) +            exit() +        return +    last = A[-1] +    if bl: +        dfs([0], i + 1, True) +        for j in range(1, 10): +            dfs([j], i + 1, False) +    else: +        if last > 0: +            dfs(A + [last - 1], i + 1, False) +        dfs(A + [last], i + 1, False) +        if last < 9: +            dfs(A + [last + 1], i + 1, False) + + +dfs([0], 0, True)