#include <bits/stdc++.h>

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define endl "\n"
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define F first
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------
set <int> v;

void bfs(int n, int m, int num) 
{ 
    // Queue will contain all the stepping Numbers 
    queue<int> q; 
  
    q.push(num); 
  
    while (!q.empty()) 
    { 
        // Get the front element and pop from the queue 
        int stepNum = q.front(); 
        q.pop(); 
  
        // If the Stepping Number is in the range 
        // [n, m] then display 
        if (stepNum <= m && stepNum >= n) 
            v.insert(stepNum);
  
        // If Stepping Number is 0 or greater than m, 
        // need to explore the neighbors 
        if (num == 0 || stepNum > m) 
            continue; 
  
        // Get the last digit of the currently visited 
        // Stepping Number 
        int lastDigit = stepNum % 10; 
  
        // There can be 2 cases either digit to be 
        // appended is lastDigit + 1 or lastDigit - 1 
        int stepNumA = stepNum * 10 + (lastDigit- 1);
        int stepNumC = stepNum * 10 + (lastDigit); 
        int stepNumB = stepNum * 10 + (lastDigit + 1); 
  
        // If lastDigit is 0 then only possible digit 
        // after 0 can be 1 for a Stepping Number 
        if (lastDigit == 0) {
            q.push(stepNumB);
            q.push(stepNumC); 
        }
  
        // If lastDigit is 9 then only possible 
        // digit after 9 can be 8 for a Stepping 
        // Number 
        else if (lastDigit == 9) { 
            q.push(stepNumA); 
            q.push(stepNumC);
        }
  
        else
        { 
            q.push(stepNumA); 
            q.push(stepNumB);
            q.push(stepNumC); 
        } 
    } 
} 

void store(int n, int m) {
    for(int i=0;i<=9;i++)
        bfs(n, m, i);
}

void solve() {
    int k;
    cin >> k;
    store(0, 3234566668);  
    int v1[200005] = {0};
    int i=0;
    for(auto it = v.begin(); it != v.end(); ++it) {
        // cout << *it << " ";
        int z = *it;
        v1[i] = z;
        ++i;
    }
    cout << v1[k];
    return;
}

int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 6528