/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

//void add(int I, int value){seg[I += MAXN] = value;for (I >>= 1; I; I >>= 1){seg[I] = __gcd(seg[I << 1], seg[I << 1 | 1]);}}

//int query(int l, int r){int ans = seg[l + MAXN];for (l += MAXN, r += MAXN + 1; l < r; l >>= 1, r >>= 1){if(l & 1) ans = __gcd(ans, seg[l ++]);if(r & 1) ans = __gcd(ans, seg[-- r]);}return ans;}

const int MAXN = 1e6 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll mod)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod : pw(a * a % mod, b / 2, mod))); }

string N(string x)
{
        string cu = "";
        vector < ll > d;
        for(int i = (int)x.size() - 1; ~i; i--)
        {
                d.push_back((int)(x[i] - '0'));
        }
        for(ll i = 0; i < (int)d.size() - 1; i++)
        {
                if(abs(d[i] + 1 - d[i + 1]) <= 1 && d[i] + 1 <= 9)
                {
                        d[i]++;
                        for(int j = (int)d.size() - 1; ~j; j--)
                        {
                                if(j >= i)
                                {
                                        cu += string(1, d[j] + '0');
                                }
                                else
                                {
                                        d[j] = max(d[j + 1] - 1, 0ll);
                                        cu +=  string(1, '0' + max(d[j + 1] - 1, 0ll));
                                }
                        }
                        return cu;
                }
        }
        if(d.back() == 9)
        {
                cu = "1";
                for(int i = 0; i < (int)d.size(); i++)
                {
                        cu += "0";
                }
                return cu;
        }
        else
        {
                d[(int)d.size() - 1] ++;
                cu = string(1, d.back() + '0');
                for(int j = (int)d.size() - 2; ~j; j--)
                {
                        d[j] = max(d[j + 1] - 1, 0ll);
                        cu += string(1, '0' + max(d[j + 1] - 1, 0ll));
                }
                return cu;
        }

}

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int k;
    cin >> k;
    string ans = "1";
    while(k > 1)
    {
            //cout << ans << endl;
            ans = N(ans);
            k--;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256