#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define insert in
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
set<ll> v;
//vector<ll> v;
void dfs(ll n, ll m, ll stepNum)
{
    // If Stepping Number is in the
    // range [n,m] then display
    if(stepNum>=n && stepNum<=m)
        v.insert(stepNum);
  
    // If Stepping Number is 0 or greater
    // than m, then return
    if (stepNum == 0 || stepNum > m)
        return ;
  
    // Get the last digit of the currently
    // visited Stepping Number
    ll lastDigit = stepNum % 10;
  
    // There can be 2 cases either digit
    // to be appended is lastDigit + 1 or
    // lastDigit - 1
    ll stepNumC=stepNum*10;
//    v.insert(stepNumC);
//    v.insert(stepNumC+lastDigit);
    ll stepNumA = stepNum*10 + (lastDigit-1);
    ll stepNumB = stepNum*10 + (lastDigit+1);
  
    // If lastDigit is 0 then only possible
    // digit after 0 can be 1 for a Stepping
    // Number
    if (lastDigit == 0){
        dfs(n, m, stepNumB);
        dfs(n,m,stepNumC);
    }
  
    // If lastDigit is 9 then only possible
    // digit after 9 can be 8 for a Stepping
    // Number
    else if(lastDigit == 9){
        dfs(n, m, stepNumA);
        dfs(n,m,stepNumC+lastDigit);
    }
    else
    {
        dfs(n, m, stepNumA);
        dfs(n, m, stepNumB);
//         dfs(n,m,stepNumC);
        dfs(n,m,stepNumC+lastDigit);
    }
}
  
// Method displays all the stepping
// numbers in range [n, m]
void displaySteppingNumbers(ll n, ll m)
{
    // For every single digit Number 'i'
    // find all the Stepping Numbers
    // starting with i
    for (ll i = 0 ; i <= 9 ; i++)
        dfs(n, m, i);
}
int main(){
    ll kk=2;
         
    while(kk<=10){
        ll s1=1,s2=2,s3=3,s4=4,s5=5,s6=6,s7=7,s8=8,s9=9;
            if(kk==1){
                for(ll m=1;m<kk;m++){
                                   s2=s2*10+2;
                               }
                for(ll m=1;m<kk;m++){
                                   s3=s3*10+3;
                               }
                for(ll m=1;m<kk;m++){
                                   s4=s4*10+4;
                               }
                for(ll m=1;m<kk;m++){
                                   s5=s5*10+5;
                               }
                for(ll m=1;m<kk;m++){
                                   s6=s6*10+6;
                               }
                for(ll m=1;m<kk;m++){
                                   s7=s7*10+7;
                               }
                for(ll m=1;m<kk;m++){
                                   s8=s8*10+8;
                               }
                for(ll m=1;m<kk;m++){
                                   s9=s9*10+9;
                               }
                
            }
            else{
          for(ll m=1;m<kk;m++){
                 s1=s1*10+1;
             }
             for(ll m=1;m<kk;m++){
                                s2=s2*10+2;
                            }
             for(ll m=1;m<kk;m++){
                                s3=s3*10+3;
                            }
             for(ll m=1;m<kk;m++){
                                s4=s4*10+4;
                            }
             for(ll m=1;m<kk;m++){
                                s5=s5*10+5;
                            }
             for(ll m=1;m<kk;m++){
                                s6=s6*10+6;
                            }
             for(ll m=1;m<kk;m++){
                                s7=s7*10+7;
                            }
             for(ll m=1;m<kk;m++){
                                s8=s8*10+8;
                            }
             for(ll m=1;m<kk;m++){
                                s9=s9*10+9;
                            }

             
                    
    }
        v.insert(s1),  v.insert(s2),  v.insert(s3),  v.insert(s4),  v.insert(s5),  v.insert(s6),  v.insert(s7),  v.insert(s8),  v.insert(s9);
        kk++;
    }

    ll n=1, m=1e10;
    displaySteppingNumbers(n,m);
    ll k; cin>>k;
    auto it=v.begin();
    for(ll i=1;i<k;i++){
        it=next(it);
    }
    cout<<*it;
    return 0;
}


Measured memory_bytes: 9600