//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
ll dp[300][11];
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>k;
for(int i=0;i<=9;i++)
dp[1][i]=1;
for(int i=2;i<=30;i++)
{
    for(int f=0;f<=9;f++)
    {
        {
            if(f-1!=-1)
            dp[i][f]+=dp[i-1][f-1];
            dp[i][f]+=dp[i-1][f];
            if(f+1!=10)
            dp[i][f]+=dp[i-1][f+1];
        }
    }
}
    ll sum=0;
    int firstdig=-1;
    int len=-1;
    string s;
    if(k<=9)
    {
        cout<<k;
        return ;
    }
    k-=9;
    deb(k);
    bool f=0;
    for(int i=2;i<=20;i++)
    {
        for(int j=1;j<=9;j++)
        {
        sum+=dp[i][j];
        if(sum==k)
        {
            s.pb(j+'0');
            int last=j;
            for(int x=1;x<i;x++)
            {
             s.pb(min(last+1,9)+'0');
             last=min(last+1,9);
            }
            cout<<s;
            return ;
        }
        if(sum>k)
        {
        sum-=dp[i][j];
        k-=sum;
        firstdig=j;
        len=i-1;
        s.pb(firstdig+'0');
        f=1;
        break;
        }
        }
        if(f)
        break;
    }
while(len>0)
{
    ll sum=0;
    for(int j=firstdig-1;j<=min(firstdig+1,(int)9);j++)
    {
    sum+=dp[len][j];
    if(sum==k)
    {
            s.pb(j+'0');
            int last=j;
            for(int x=0;x<len-1;x++)
            {
             s.pb(min(last+1,9)+'0');
             last=min(last+1,9);
            }
            cout<<s;
            return ;
    }
    if(sum>k)
    {
        sum-=dp[len][j];
        k-=sum;
        len--;
        s.pb(j+'0');
        firstdig=j;
        break;
    }
    }

}
return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256