#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    //ll k; cin >> k;
    ll K; cin >> K;
    //for(int K = 1; K <= k; K++){
        vector<vector<ll>> DP(11, vector<ll>(11));
        ll cnt = 0;
        bool flag = false;

        for(int i = 1; i < 11; i++) {
            for(int j = 0; j < 10; j++){
                if(i == 1) {
                    DP[i][j] = 1;
                    if(j != 0)cnt += DP[i][j];
                }
                else {
                    if(j == 0) DP[i][j] = DP[i-1][j] + DP[i-1][j+1]; 
                    else {
                        DP[i][j] = DP[i-1][j-1] + DP[i-1][j] + DP[i-1][j+1];
                        cnt += DP[i][j]; 
                    }
                }
                
                if(cnt >= K){
                    ll cnt2 = cnt - DP[i][j];
                    string tag = "";

                    tag += (char)(j+48);
                    ll cnt3 = K - cnt2;
                    //if(cnt3 == 0) {cout << tag << endl; return 0;}
                    if(i == 1) {cout << tag << endl; flag = true; break;return 0;}
                    //if(i == 1) {cout <<K << " "<< tag << endl; flag = true; break;return 0;}
                    //cout << cnt3 << " " << i << " " << j << endl;


                    while(i > 1){
                        //if(K == 35)cout << i << " " << j  << " " << cnt3 << " "<<tag << endl;
                        if(j == 0){
                            if(0 <= cnt3 && cnt3 <= DP[i-1][j]){
                                //cnt3 -= DP[i-1][0];
                                tag += to_string(j);
                                i--;
                                j = j;
                            }
                            else {
                                cnt3 -= DP[i-1][j];
                                tag += to_string(j+1);
                                i--;
                                j = j+1;
                            }
                        }
                        else if(j == 9){
                            if(0 <= cnt3 && cnt3 <= DP[i-1][j-1]){
                                //cnt3 -= DP[i-1][0];
                                tag += to_string(j-1);
                                i--;
                                j = j-1;
                            }
                            else {
                                cnt3 -= DP[i-1][j-1];
                                tag += to_string(j);
                                i--;
                                j = j;
                            }
                            //cout << tag << endl;
                        }
                        else{
                        if( 0 <= cnt3 && cnt3 <= DP[i-1][j-1]){
                            //cnt3 -= DP[i-1][j-1]-1;
                            //cnt3 -= DP[i-1][j-1]-1;
                            tag += to_string(j-1);
                            //cnt3 += ;
                            i--;
                          j--;
                            //j = max(j-1, 0);
                        }
                        else if( DP[i-1][j-1] < cnt3 && cnt3 <=  DP[i-1][j-1] + DP[i-1][j]){
                            //cnt3 -= DP[i-1][j-1] + DP[i-1][j]-1;
                            cnt3 -= DP[i-1][j-1];
                            tag += to_string(j);
                            i--;
                            j = j;
                        }
                        else{
                            //cnt3 -= DP[i-1][j-1] + DP[i-1][j] + DP[i-1][j+1]-1;
                            cnt3 -= DP[i-1][j-1] + DP[i-1][j];
                            tag += to_string(j+1);
                            i--;
                            j = j+1;
                        }
                        }
                        if(i == 1) {cout <<  tag << endl;flag = true; break; return 0;}
                        //if(i == 1) {cout <<K <<" "<<  tag << endl;flag = true; break; return 0;}

                    }
                    if(flag) break;
                }
                if(flag) break;
            }
        if(flag) break;
        }
    //}

}


Measured memory_bytes: 256