#include <cstdio>
#include <iostream>
using namespace std;
int humble[6000];
int MIN_4(int a,int b,int c,int d)
{
int min1=a>b?b:a;
int min2=c>d?d:c;
return min1>min2?min2:min1;
}
void init()
{
humble[1]=1;
int a=1,b=1,c=1,d=1;
int ans;
for(int n=2;n<=5842;n++)
{
ans=MIN_4(humble[a]*2,humble[b]*3,humble[c]*5,humble[d]*7);
humble[n]=ans;
if(ans%2==0) a++;
if(ans%3==0) b++;
if(ans%5==0) c++;
if(ans%7==0) d++;
}
}
int main()
{
int n;
init();
while(cin>>n&&n)
{
if(n%10==1&&n%100!=11)
printf("The %dst humble number is %d.\n",n,humble[n]);
else if(n%10==2&&n%100!=12)
printf("The %dnd humble number is %d.\n",n,humble[n]);
else if(n%10==3&&n%100!=13)
printf("The %drd humble number is %d.\n",n,humble[n]);
else
printf("The %dth humble number is %d.\n",n,humble[n]);
}
return 0;
}