#include <stdio.h>
#include <stdlib.h>

int main()
{
	int K;
	scanf("%d", &K);
	
	int i, j, d = 0, X[100] = {1};
	for (i = 1; i < K; i++) {
		for (j = 0; j < d; j++) if (X[j] != 9 && X[j] <= X[j+1]) break;
		if (j < d || X[j] != 9) {
			for (X[j--]++; j >= 0; j--) X[j] = (X[j+1] > 0)? X[j+1] - 1: 0;
		} else {
			X[++d] = 1;
			for (j = 0; j < d; j++) X[j] = 0;
		}
	}
	
	for (i = d; i >= 0; i--) printf("%d", X[i]);
	fflush(stdout);
	return 0;
}