import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto k = readln.chomp.to!int;

  auto x = [
       [0, 1],
    [0, 1, 2],
    [1, 2, 3],
    [2, 3, 4],
    [3, 4, 5],
    [4, 5, 6],
    [5, 6, 7],
    [6, 7, 8],
    [7, 8, 9],
    [8, 9]
  ];
  int cnt;
  int a;

  auto num = new int[](10);
  void calc(int i) {
    if (i == a) {
      cnt++;
      if (cnt == k) {
        writefln("%(%s%|%)", num[0..a]);
      }
    } else {
      foreach (c; x[num[i-1]]) {
        num[i] = c;
        calc(i+1);
        if (cnt == k) {
          break;
        }
      }
    }
  }

  a:while (true) {
    a++;
    foreach (i; 1..10) {
      num[0] = i;
      calc(1);
      if (cnt == k) {
        break a;
      }
    }
  }
}
