#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  queue<int> qu;
  int i = 0;
  qu.push(10);
  while (i != n) {
    int a = qu.front();
    qu.pop();
    int last, num, p, q;
    if (a == 10) {
      last = 9;
      p = 1;
      num = 0;
      q = last;
    } else {
      last = a % 10;
      num = a / 10;
      p = 0;
      q = last;
    }
    while (p != last + 1) {
      i++;
      int f = num * 100 + p * 10 + q;
      if (i == n) {
        cout << f;
        return 0;
      }
      qu.push(f);
      p++;
      q--;
    }
  }
  return 0;
}
