#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int cnt = 0;
int K;
void dfs(int num, int th) {
  DUMP(num, th);
  if (th == 0) {
    cnt++;
    if (cnt == K) {
      cout << "Here" << endl;
      exit(0);
    }
    return;
  }
  if (num - 1 >= 0) dfs(num - 1, th - 1);
  dfs(num, th - 1);
  if (num + 1 <= 9) dfs(num + 1, th - 1);
}
LL maxth = 1;
void add1(VEC<int> &S, int keta) {
  // auto T = S;
  // reverse(ALL(T));
  // DUMP("  ", T, keta);
  int i = keta;

  if (keta == maxth) {
    if (S[i] == 9) {
      S[i + 1] = 1;
      S[i] = 0;
      maxth++;
    } else {
      S[i]++;
    }
    for (int j = i - 1; j >= 0; j--) {
      S[j] = max(0, S[j + 1] - 1);
    }
    return;
  }

  if (abs(S[i + 1] - S[i] - 1) <= 1 && S[i] + 1 <= 9) {
    S[i]++;
  } else {
    // carry
    add1(S, keta + 1);
    for (int j = keta; j >= 0; j--) {
      S[j] = max(0, S[j + 1] - 1);
    }
    // if (S[i + 1] != 9) {
    //   S[i] = S[i + 1];
    //   swap(S[i], S[i + 1]);
    //   // add1(S, keta + 1);
    // } else {
    //   S[i + 1] = 1;
    // }
  }
}
// bool valid(int K) {
//   int pre = K % 10;
//   while (K > 0) {
//     int t = K % 10;
//     if (abs(pre - t) > 1) {
//       return 0;
//     }
//     K /= 10;
//   }
//   return 1;
// }

int main() {
  cin >> K;
  if (K <= 10) {
    cout << K << endl;
    return 0;
  }
  // REP(keta, 0, 10) {
  //   REP(i, 0, 10) { dfs(i, keta); }
  // }

  // int count = 0;
  // LL k = 1;
  // while (true) {
  //   DUMP(k);
  //   if (valid(k))
  //     count++;
  //   else {
  //     DUMP((LL)log10(k),pow(10,(LL)log10(k)));
  //     k += (LL)pow(10,(LL)log10(k))-8;
  //     continue;
  //   }
  //   if (count == K) {
  //     cout << k << endl;
  //     return 0;
  //   }
  //   k++;
  // }

  VEC<int> S(30, 0);
  S[1] = 1;
  for (int k = 11; k <= K; k++) {
    add1(S, 0);
    // auto T = S;
    // reverse(ALL(T));
    // DUMP(k, T);
  }
  auto T=S;
  reverse(ALL(T));
  // DUMP(T);
  REP(i,0,T.size()){
    if(T[i]==0)continue;
    else{
      REP(j,i,30){
        cout<<T[j];
      }
      break;
    }
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256