#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define LLFOR(i, s, n) for(ll i = (s), i##_len=(n); i < i##_len; ++i)
#define LLFORS(i, s, n) for(ll i = (s), i##_len=(n); i <= i##_len; ++i)
#define LLVFOR(i, s, n) for(ll i = (s); i < (n); ++i)
#define LLVFORS(i, s, n) for(ll i = (s); i <= (n); ++i)
#define LLREP(i, n) LLFOR(i, 0, n)
#define LLREPS(i, n) LLFORS(i, 0, n)
#define LLVREP(i, n) LLVFOR(i, 0, n)
#define LLVREPS(i, n) LLVFORS(i, 0, n)
#define LLRFOR(i, s, n) for(ll i = (s). i##_len=(n); i >= i##_len; --i)
#define LLRFORS(i, s, n) for(ll i = (s), i##_len=(n); i > i##_len; --i)
#define LLRREP(i, n) LLRFOR(i, n, 0)
#define LLRREPS(i, n) LLRFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(RALL(v))
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}



vector<VI> dp(11, VI(10, 0));//dp[i][j] := i桁でj始まりのルンルン数の数
VI keta(12, 0);//keta[i] := i桁のルンルン数の最初は何番目か
vector<VI> ketaInit(12, VI(10, 0));
void init(){
    REP(i, 10) dp[1][i] = 1;
    FORS(i, 2, 10){
        REP(j, 10){
            if(j)     dp[i][j] += dp[i-1][j-1];
            dp[i][j] += dp[i-1][j];
            if(j < 9) dp[i][j] += dp[i-1][j+1];
        }
    }

    keta[1] = 1;
    FORS(i, 1, 10){
        keta[i+1] = keta[i];
        FORS(j, 1, 9)
            keta[i+1] += dp[i][j];
    }
    /*  FOR(i, 1, 12){
    cout << i << " : " << keta[i] << endl;
    }*/
    FORS(i, 1, 10){
        ketaInit[i][1] = keta[i];
        FOR(j, 1, 9)
            ketaInit[i][j+1] = ketaInit[i][j] + dp[i][j];
    }
    ketaInit[11][1] = keta[11];
}
string Thissearch(int N, int ii, int jj){
    if(ii == 1) return "";
    int a(0), b(0);
    FORS(dj, -1, 1){
        int j(jj+dj);
        if(j < 0 || j > 9) continue;
        a += dp[ii-1][j];
        if(a > N){
            string ret; ret += char(j + '0');
            int n(N - a + dp[ii-1][j]);
            return ret + Thissearch(n, ii-1, j);
        }
    }
}

string search(int N){
    string ans("");
    FORS(i, 1, 10){
        FORS(j, 1, 9){
            if(N < ketaInit[i][j]){
                if(j > 1) --j;
                else{ --i; j = 9;}
                ans += char('0' +  j);
                if(i > 1) ans += Thissearch(N-ketaInit[i][j], i, j);
                return ans;
            }
        }
    }
}

int main(){
    int N; cin >> N;
    init();
    
   /* FORS(i, 1, 10){
        FORS(j, 1, 9){
            cout << i << ", " << j << ": " << ketaInit[i][j] << endl;
        }
    }*/
  /*  while(N){
        bool skip(false);
        FORS(i, 1, 10){
            FORS(j, 1, 9){
                if(N < ketaInit[i][j]){
                    if(j > 1) --j;
                    else{ --i; j = 9;}
                    cout << j;
                    if(N == ketaInit[i][j]){
                        REP(ii, i-1) cout << 0;
                        cout << endl;
                        return 0;
                    }
                    N -= ketaInit[i][j];
                    skip = true;
                    break;
                }
            }
            if(skip){
                skip = false;
                break;
            }
        }
    }*/
    cout << search(N) << endl;
    return 0;
}


Measured memory_bytes: 256