#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD2; 
int dp[30][10];
int ans[200005];
vector<int> v[10];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
           int k;
           cin>>k;
           int k1=k;
           rep(i,0,10)dp[1][i]=1;
            rep(i,0,10)
            {
                  if(i-1>=0)v[i].push_back(i-1);
                  v[i].push_back(i);
                  if(i+1<10)v[i].push_back(i+1);
            }
            
           rep(i,2,30)
           {
                 rep(j,0,10)
                 {
                      if(j==0)
                      {
                          dp[i][j]=dp[i-1][0]+dp[i-1][1];
                      }
                      else if(j==9)
                      {
                          dp[i][j]=dp[i-1][8]+dp[i-1][9];
                      }
                      else
                      {
                          dp[i][j]=dp[i-1][j]+dp[i-1][j+1]+dp[i-1][j-1];
                      }  
                 }
           }

           int start=-1;
           
           rep(i,1,15)
           {
               int tot=0;
               rep(j,1,10)tot+=dp[i][j];
               if(tot<k)
               {
                    k-=tot;
                    continue; 
               }
               else
               {
                   start=i;
                   break;
               }   
           }

           int prev=-1;
           rev(i,start,1)
           {

                 if(prev==-1)
                 {
                     int tot=0;
                     rep(j,1,10)
                     {
                         tot=dp[i][j];
                         if(tot<k)
                         {
                             k-=tot;
                             continue; 
                         }
                         else
                         { 
                              ans[i]=j;
                              prev=j;
                              break;
                         }     
                     }
                 }
                 else
                 {
                       int tot=0;
                       for(auto it:v[prev])
                       {
                            tot=dp[i][it];
                            if(tot<k)
                            {
                               k-=tot;
                               continue;
                            }
                            else
                            {
                                ans[i]=it;
                                prev=it;
                                break;
                            }  
                       } 
                 } 
           }
           reverse(ans+1,ans+start+1);
           rep(i,1,start+1)cout<<ans[i];
           cout<<endl;


      }
      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 256