#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[100][10];
int mm[100][10][10];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int cc;
   cin>>cc;
   if(cc<=9)
   {
      cout<<cc;
      return 0;
   }
   for(int i=1;i<=9;i++)
   {
      dp[1][i]=1;
   }
   int ans=9;
   int ind=1;
   int prev=9;
   for(int i=2;i<=99;i++)
   {
      for(int j=0;j<10;j++)
      {
         dp[i][j]+=dp[i-1][j];
         if(j>0)
         dp[i][j]+=dp[i-1][j-1];
         if(j<9)
         dp[i][j]+=dp[i-1][j+1];
         ans+=dp[i][j];         
      }
      if(ans>=cc)
      {
         ind=i;
         break;
      }
      prev=ans;
   }

   for(int i=0;i<10;i++)
      mm[1][i][i]=1;
      
   for(int i=2;i<=ind;i++)
   {
      for(int j=0;j<10;j++)
      {
         for(int k=0;k<10;k++)
         {
            mm[i][j][k]+=mm[i-1][j][k];
            if(k>0)
            mm[i][j][k]+=mm[i-1][j][k-1];
            if(k<9)
            mm[i][j][k]+=mm[i-1][j][k+1];            
         }
      }
   }

   vector<int>str;
   cc-=prev;

   int z=0;
   bool flag=false;
   for(int j=1;j<10&&!flag;j++)
   {
         for(int l=0;l<10;l++)
         {
            z+=mm[ind][j][l];
         }
            if(z>=cc)
            {      
               flag=true;   
               str.push_back(j);
               break;
            }
            cc-=z;
            z=0;
   }

   for(int i=1;i<ind;i++)
   {
      int x=str.back();
      int z=0;
      bool flag=false;
      if(x>0)
      {
         for(int j=0;j<10;j++)
         {
            z+=mm[ind-i][x-1][j];
            if(z>=cc)
            {
               flag=true;
               str.push_back(x-1);
               break;
            }
         }
         if(flag)
            continue;
            cc-=z;
            z=0;
      }
      z=0;

      if(flag)
         continue;
      for(int j=0;j<10;j++)
      {
         z+=mm[ind-i][x][j];
         if(z>=cc)
         {
            flag=true;
            str.push_back(x);
            break;
         }
      }
      if(flag)
         continue;
         cc-=z;
         z=0;
      if(x<9)
      {
         for(int j=0;j<10;j++)
         {
            z+=mm[ind-i][x+1][j];
            if(z>=cc)
            {
               flag=true;
               str.push_back(x+1);
               break;
            }
         }
         if(flag)
            continue;
            cc-=z;
            z=0;
      }
   }

   for(auto i:str)
      cout<<i;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 256