# -*- coding: utf-8 -*-

from collections import deque

k = int(eval(input()))



dq = deque(list(range(1, 10)))

rep = 0

while rep < k:

    now = dq.popleft()

    rep+=1

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

        if 0<=now%10+i<10:

            dq.append(now*10+now%10+i)

print(now)

def main():

    k = int(eval(input()))

    a = [i for i in range(1,10)]

    x = 0

    while(1):

        if k <= len(a):

            print((a[k-1]))

            return

        for i in range(-1,2):

            d = a[x]%10 +i

            if 0 <= d and d < 10:

                a.append(a[x]*10 + d)

        x+=1



if __name__ == "__main__":

    main()
# -*- coding: utf-8 -*-
from collections import deque

k = int(eval(input()))
dq = deque(list(range(1, 10)))
rep = 0
while rep < k:
    now = dq.popleft()
    rep += 1
    for i in (-1, 0, 1):
        if 0 <= now % 10 + i < 10:
            dq.append(now * 10 + now % 10 + i)
print(now)

def main():
    k = int(eval(input()))
    a = [i for i in range(1, 10)]
    x = 0
    while 1:
        if k <= len(a):
            print((a[k - 1]))
            return
        for i in range(-1, 2):
            d = a[x] % 10 + i
            if 0 <= d and d < 10:
                a.append(a[x] * 10 + d)
        x += 1


if __name__ == "__main__":
    main()

-# -*- coding: utf-8 -*- -from collections import deque +def main(): +    k = int(eval(input())) +    a = [i for i in range(1, 10)] +    x = 0 +    while 1: +        if k <= len(a): +            print((a[k - 1])) +            return +        for i in range(-1, 2): +            d = a[x] % 10 + i +            if 0 <= d and d < 10: +                a.append(a[x] * 10 + d) +        x += 1 -k = int(eval(input())) -dq = deque(list(range(1, 10))) -rep = 0 -while rep < k: -    now = dq.popleft() -    rep += 1 -    for i in (-1, 0, 1): -        if 0 <= now % 10 + i < 10: -            dq.append(now * 10 + now % 10 + i) -print(now) + +if __name__ == "__main__": +    main()