#include<bits/stdc++.h>
using namespace std;
int k,f,r=9,num=9;
long long q[200001]={0,1,2,3,4,5,6,7,8,9}; 
int main()
{
	cin>>k;
	if(k<10) cout<<q[k];
	while(f!=r)
	{
		f=(f+1)%200001;
		for(int i=-1;i<=1;++i)
		{
			if(q[f]%10+i<0||q[f]%10+i>9) continue;
			r=(r+1)%200001;
			q[r]=q[f]*10+q[f]%10+i;
			++num;
			if(num==k)
			{
				cout<<q[r];
				return 0;
			}
		}
	}
}