#include <iostream>
using namespace std;
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
#define md 998244353
#define md1 998244353 
#define pb push_back
#define in insert
#define mkp make_pair
#define f(i,yha,wha) for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha) for(ll i=wha;i>=yha;i--)
#define mpll map<ll,ll>
#define len(p) p.size()
#define pll pair<ll,ll>
#define arr_sort_rev(arr,n) sort(arr, arr+n, greater<ll>());
#define vec_sort_rev(v) sort(v.begin(), v.end(), greater<ll>());
#define arr_sort(arr,n) sort(arr,arr+n)
#define vec_sort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define mem(a,t) memset(a,t,sizeof(a))
#define endl "\n"

void flash()
{
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
}

ll pw(ll x,ll y)
{
    if(y==0)
      return 1;
    if(y==1)
      return x;
    ll ans=pw(x,y/2);
    ans=ans*ans;
    if(y%2==1)
        ans=ans*x;
    return ans;
}
 
ll pwm(ll x,ll y)
{
    if(y==0)
      return 1;
    if(y==1)
      return x;
    ll ans=pwm(x,y/2)%md;
    ans=(ans*ans)%md;
    if(y%2==1)
        ans=(ans*x)%md;
    return ans;
}
 
int check(ll n)
{
    if(n<0)
      return 0;
    else
      return 1;
}
 
ll add(ll a,ll b)
{
    return a+b;
}
 
ll max(ll a,ll b)
{
    if(a>b)
      return a;
     else
      return b;
}
 
ll min(ll a,ll b)
{
    if(a>b)
      return b;
     else
      return a;
}

ll minv(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m,t = m; 
        m = a % m, a = t,t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
bool cmp(ll i1,ll i2) 
{ 
   
    // i1<i2 for increasing order
    // i1>i2 for decreasing order
    return (i1 > i2); 
}

void solve()
{
	
    ll k;
    cin>>k;
    ll dp[20][15];
    ll dp1[20][15];
    memset(dp,0,sizeof(dp));
    memset(dp1,0,sizeof(dp1));
    for(int i=0;i<=9;i++){
       dp[1][i]=1;
       dp1[1][i]=1;
   }
 
	for(int i=2;i<=15;i++)
	{
		for(int j=0;j<=9;j++)
		{
			if(j>0)
			dp[i][j]+=dp[i-1][j-1];
			dp[i][j]+=dp[i-1][j];
			if(j<9)
			dp[i][j]+=dp[i-1][j+1];
		}
	}
	for(int i=1;i<=15;i++)
	{
		for(int j=0;j<=9;j++)
		{
			dp1[i][j]=dp[i][j];
		}
	}
	
	
	ll tmp=0;
	
//	for(int i=1;i<=15;i++)
//	{
//	    for(int j=0;j<=9;j++)
//	    {
//	    	cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//    }
	
	for(int i=1;i<=15;i++)
	{
		dp[i][1]+=dp[i-1][9];
	
	    for(int j=2;j<=9;j++)
	    {
	    	dp[i][j]+=dp[i][j-1];
		}
    }
    
//    for(int i=1;i<=15;i++)
//	{
//	    for(int j=0;j<=9;j++)
//	    {
//	    	cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//    }
    int loc=-1;
    int ele;
    for(int i=1;i<=15;i++)
	{
	    for(int j=1;j<=9;j++)
	    {
	       if(dp[i][j]>=k)
		   {
		   	   if(j>1)
		   	   k-=dp[i][j-1];
		   	   else
		   	     k-=dp[i-1][9];
		   	   loc=i;
		   	   ele=j;
		   	   break;
		   }	
		}
		if(loc!=-1)
		 break;
    }
//    cout<<loc<<endl;
    cout<<ele;
    
    for(int i=loc-1;i>=1;i--)
    {
    	
    	if(ele>0 and dp1[i][ele-1]>=k)
    	{
    		cout<<ele-1;
    		ele-=1;
    		continue;
		}
		if(ele>0)
		  k-=dp1[i][ele-1];
		if(dp1[i][ele]>=k)
		{
			cout<<ele;
			continue;
		}
		k-=dp1[i][ele];
		
		cout<<ele+1;
		ele+=1;
		
		
    	
	}
	//cout<<endl;
//	cout<<k<<endl;
	
	
	
	
        
    
}

int main()
{
    flash();
    int t;
    t=1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256