from collections import deque

K = int(eval(input()))

q = deque([0])



cnt = 0

ans = []

while q:

  a = q.popleft()

  r = a % 10

  a *= 10

  for i in range(10):

    if abs(r - i) <= 1 or a == 0:

      if cnt < K and a + i != 0:

        q.append(a + i)

        ans.append(a + i)

        cnt += 1



print((ans[-1]))
from collections import deque

K = int(eval(input()))

q = deque([0])



cnt = 0

while q:

  n = q.popleft()

  r = n % 10; n *= 10;

  for i in range(10):

    if abs(r - i) <= 1 or n == 0:

      if n + i != 0:

        q.append(n + i)

        cnt += 1

        if cnt == K:

          print((n+i))

          exit()
from collections import deque

K = int(eval(input()))
q = deque([0])
cnt = 0
ans = []
while q:
    a = q.popleft()
    r = a % 10
    a *= 10
    for i in range(10):
        if abs(r - i) <= 1 or a == 0:
            if cnt < K and a + i != 0:
                q.append(a + i)
                ans.append(a + i)
                cnt += 1
print((ans[-1]))

from collections import deque

K = int(eval(input()))
q = deque([0])
cnt = 0
while q:
    n = q.popleft()
    r = n % 10
    n *= 10
    for i in range(10):
        if abs(r - i) <= 1 or n == 0:
            if n + i != 0:
                q.append(n + i)
                cnt += 1
                if cnt == K:
                    print((n + i))
                    exit()

-ans = [] -    a = q.popleft() -    r = a % 10 -    a *= 10 +    n = q.popleft() +    r = n % 10 +    n *= 10 -        if abs(r - i) <= 1 or a == 0: -            if cnt < K and a + i != 0: -                q.append(a + i) -                ans.append(a + i) +        if abs(r - i) <= 1 or n == 0: +            if n + i != 0: +                q.append(n + i) -print((ans[-1])) +                if cnt == K: +                    print((n + i)) +                    exit()