"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var k = next();
  var x = 10, ans = xArray(-1,x+1);
  ans[x] = 1;
  for(var i = 1; i < k; i++){
    if((ans[x-1] < 0 || ans[x-1] >= ans[x]) && ans[x] !== 9){
      ans[x]++;
      continue;
    }
    for(var j = x; --j;){
      if((ans[j-1] < 0 || ans[j-1] >= ans[j]) && ans[j] !== 9)break;
    }
    if(ans[j] === -1)ans[j] = 0;
    ans[j++]++;
    for(; j <= x; j++){
      if(ans[j-1])ans[j] = ans[j-1] - 1;
      else ans[j] = 0;
    }
  }
  for(var i = 0; i < x; i++)if(ans[i] === -1)ans[i] = 0;
  return +ans.join("");
}