//* Problem  : H - Humble Numbers
//* Contest  : UzhNU Local
//* Origin   : Ulm-1996
//* Type     : Solution
//* Date     : 2008.02.04
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : Straightforward

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

#define int64 __int64

int n, a[10000], r;

int cmp_f(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

void fill()
{
	int r = 0;
	for (int64 i2 = 1; i2 <= 2000000000; i2*=2)
		for (int64 i3 = 1; i3 <= 2000000000; i3*=3)
			for (int64 i5 = 1; i5 <= 2000000000; i5*=5)
				for (int64 i7 = 1; i7 <= 2000000000; i7*=7)
				{
					if (i2 * i3 > 2000000000) continue;
					if (i5 * i7 > 2000000000) continue;
					if (i2 * i3 * i5 * i7 > 2000000000) continue;
					a[r++] = i2 * i3 * i5 * i7;
				}
//	printf("%d\n", r);
	qsort(a, r, sizeof(a[0]), cmp_f);
}

void suffix()
{
	if (n %100 >= 10 && n%100 < 20) {printf("th"); return;}
	if (n%10 == 1) {printf("st"); return;}
	if (n%10 == 2) {printf("nd"); return;}
	if (n%10 == 3) {printf("rd"); return;}
	printf("th");
}

int main()
{
	fill();
	int nt = 0;
	while (1)
	{
		if (scanf("%d", &n) != 1 || !n) break;
		printf("The %d", n);
		suffix();
		printf(" humble number is %d.\n", a[n-1]);
	}
	return 0;
}