#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int n;
int lunlun_count = 0;
int dfs(int rest_digit, int num) {
  // 答えを見つけた場合
  if(rest_digit == 0 && lunlun_count == n-1) {
    return num;
  }

  if(rest_digit == 0) {
    ++lunlun_count;
    return 0;
  }

  // 残り桁がまだある場合
  int last_d = num%10;
  int ans;
  if(last_d == 9) {
    for(int i = last_d-1; i <= last_d; ++i) {
      ans = dfs(rest_digit-1, num*10 + i);
      if(ans) return ans;
    }
  } else if(last_d == 0) {
    for(int i = last_d; i <= last_d+1; ++i) {
      ans = dfs(rest_digit-1, num*10 + i);
      if(ans) return ans;
    }
  } else {
    for(int i = last_d-1; i <= last_d+1; ++i) {
      ans = dfs(rest_digit-1, num*10 + i);
      if(ans) return ans;
    }
  }

  // 残り桁の探索を追えても見つけられなかったとき
  return 0;
}
/***** MAIN *****/
signed main() {
  n = in();
  if(n < 10) {
    cout << n << endl;
    return 0;
  }
  int ans = 0;
  int current_digit = 1;
  while(!ans) {
    for(int i = 1; i <= 9; ++i) {
      ans = dfs(current_digit-1,i);
      if(ans) break;
    }
    ++current_digit;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256