#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    int k;
    cin >> k;

    vector<string> runs1 = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
    vector<string> runs2;
    vector<string> runs3;
    vector<string> runs4;
    vector<string> runs5;
    vector<string> runs6;
    vector<string> runs7;
    vector<string> runs8;
    vector<string> runs9;
    vector<string> runs10;
    vector< vector<string> > runs = {runs1, runs2, runs3, runs4, runs5, runs6, runs7, runs8, runs9, runs10};
    rep(i, 9) {
        for (const auto &run : runs[i]) {
            switch (run.back()) {
                case '0':
                    runs[i+1].push_back(run + "0");
                    runs[i+1].push_back(run + "1");
                    break;
                case '1':
                    runs[i+1].push_back(run + "0");
                    runs[i+1].push_back(run + "1");
                    runs[i+1].push_back(run + "2");
                    break;
                case '2':
                    runs[i+1].push_back(run + "1");
                    runs[i+1].push_back(run + "2");
                    runs[i+1].push_back(run + "3");
                    break;
                case '3':
                    runs[i+1].push_back(run + "2");
                    runs[i+1].push_back(run + "3");
                    runs[i+1].push_back(run + "4");
                    break;
                case '4':
                    runs[i+1].push_back(run + "3");
                    runs[i+1].push_back(run + "4");
                    runs[i+1].push_back(run + "5");
                    break;
                case '5':
                    runs[i+1].push_back(run + "4");
                    runs[i+1].push_back(run + "5");
                    runs[i+1].push_back(run + "6");
                    break;
                case '6':
                    runs[i+1].push_back(run + "5");
                    runs[i+1].push_back(run + "6");
                    runs[i+1].push_back(run + "7");
                    break;
                case '7':
                    runs[i+1].push_back(run + "6");
                    runs[i+1].push_back(run + "7");
                    runs[i+1].push_back(run + "8");
                    break;
                case '8':
                    runs[i+1].push_back(run + "7");
                    runs[i+1].push_back(run + "8");
                    runs[i+1].push_back(run + "9");
                    break;
                case '9':
                    runs[i+1].push_back(run + "8");
                    runs[i+1].push_back(run + "9");
                    break;
            }
        }
    }
    
    int accum = 0;
    rep (i, 10) {
        if (k <= accum + runs[i].size()) {
            cout << runs[i][k - accum - 1] << endl;
            break;
        }
        accum += runs[i].size();
    }

    return 0;
}


Measured memory_bytes: 6644