#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
long long a[100005]={0,1,2,3,4,5,6,7,8,9};
int main()
{
	int k;
	cin >> k;
	int tot=9;
	int p1=0,p2=1;
	while(tot<=k){
		if(abs(a[p2]%10-a[p1])<=1)
		  a[++tot]=a[p2]*10+a[p1];
		p1++;
		if(p1==10) p2++,p1=0;
	}
	cout<<a[k];
	// system("pause");
	return 0;
}
