#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll k; cin >> k; k++;
	REP(a,0,10){
		REP(b,max(0LL,a-1),10){
			if(b-a>1) if(a) break;
			REP(c,max(0LL,b-1),10){
				if(c-b>1) if(a||b) break;
				REP(d,max(0LL,c-1),10){
					if(d-c>1){
						if((a||b||c)) break;
					}
					REP(e,max(0LL,d-1),10){
						if(e-d>1){
							if(a||b||c||d) break;
						}
						REP(f,max(0LL,e-1),10){
							if(f-e>1){
								if(a||b||c||d||e) break;
							}
							REP(g,max(0LL,f-1),10){
								if(g-f>1){
									if(a||b||c||d||e||f) break;
								}
								REP(h,max(0LL,g-1),10){
									if(h-g>1){
										if(a||b||c||d||e||f||g) break;
									}
									REP(i,max(0LL,h-1),10){
										if(i-h>1){
											if(a||b||c||d||e||f||g||h) break;
										}
										REP(j,max(0LL,i-1),10){
											if(j-i>1){
												if(a||b||c||d||e||f||g||h||i) break;
											}
											k--;
											if(!k){
												bool flag = false;
												if(a) cout << a, flag = true;
												else if(flag) cout << 0;
												if(b) cout << b, flag = true;
												else if(flag) cout << 0;
												if(c) cout << c, flag = true;
												else if(flag) cout << 0;
												if(d) cout << d, flag = true;
												else if(flag) cout << 0;
												if(e) cout << e, flag = true;
												else if(flag) cout << 0;
												if(f) cout << f, flag = true;
												else if(flag) cout << 0;
												if(g) cout << g, flag = true;
												else if(flag) cout << 0;
												if(h) cout << h, flag = true;
												else if(flag) cout << 0;
												if(i) cout << i, flag = true;
												else if(flag) cout << 0;
												if(j) cout << j, flag = true;
												else if(flag) cout << 0;
												cout << endl;
												return 0;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256