#include <bits/stdc++.h>
using namespace std;
int c, K;
void f(int i, int k, int p, int64_t n)
  {if (i >= k) {++c; if (c == K) {cout << n << endl; exit(0);} else return;};
  for (int j = -1; j <= 1; ++j)
    if (0 <= p + j and p + j <= 9) f(i + 1, k, p + j, 10 * n + p + j);}
int main()
  {cin >> K;
  for (int i = 1; true; ++i) for (int j = 1; j <= 9; ++j) f(1, i, j, j);}