#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  int size = 2, i;
  int a[100000] = {0}, start;
  a[0] = 9;
  a[1] = 1;
  for (i = 1; i < k; i++) {
    start = 0;
    while (a[start] == 0) start++;
    if (start != 0) {
      a[start + 1]++;
      a[0] = a[start] - 1;
      a[start] = 0;
    } else {
      a[start + 1]++;
      a[0] = a[start] - 1;
    }
    if (a[start + 1] == 10) {
      size++;
      a[start + 2] = 1;
      a[start + 1] = 0;
      a[0] = 9;
    }
  }
  for (i = size - 1; i >= 0; i--) cout << a[i];
}
