#include <bits/stdc++.h>
#define f first
#define s second
#define rep(i, l, r) for (long long i = (l); i < (r); i++)
#define repb(i, r, l) for (long long i = (r); i > (l); i--)
#define pb push_back
 
using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull; 
const int MAX_CHAR=256;
 
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 
const ll mod = 1e9 + 7;
 
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

bool sortinrev(const pair<ll,string> &a,  
               const pair<ll,string> &b) 
{ 
       return (a.first > b.first); 
}
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}
 
bool sortbysec(const pair<ll, ll>& a, 
               const pair<ll, ll>& b) 
{ 
    return (a.second < b.second); 
} 

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}


vl v;
void bfs(ll n, ll m, ll num) 
{ 

    queue<ll> q; 
  
    q.push(num); 
  
    while (!q.empty()) 
    { 
 
        ll stepNum = q.front(); 
        q.pop(); 
  
 
        if (stepNum <= m && stepNum >= n) 
        {
            // cout << stepNum << " ";
            v.pb(stepNum);
        } 

        if (num == 0 || stepNum > m) 
            continue; 
  

        ll lastDigit = stepNum % 10; 
  

        ll stepNumA = stepNum * 10 + (lastDigit- 1); 
        ll stepNumB = stepNum * 10 + (lastDigit + 1); 
        ll stepNumC = stepNum * 10 + (lastDigit);
        

        if (lastDigit == 0) 
        {
            q.push(stepNumB); 
            q.push(stepNumC);
        }

        else if (lastDigit == 9) 
        {
            q.push(stepNumA);
            q.push(stepNumC);
        } 
  
        else
        { 
            q.push(stepNumA); 
            q.push(stepNumB);
            q.push(stepNumC);
        } 
    } 
}

void displaySteppingNumbers(ll n, ll m) 
{ 
    // For every single digit Number 'i' 
    // find all the Stepping Numbers 
    // starting with i 
    for (ll i = 0 ; i <= 9 ; i++) 
        bfs(n, m, i); 
} 

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll n=1,m=3234566668;
        
        displaySteppingNumbers(n,m); 
        
        sort(v.begin(),v.end());
        ll pos;
        cin >> pos;
        
        cout << v[pos-1];
    }
}


Measured memory_bytes: 1636