1 #include<iostream>
2 #include<algorithm>
3 #include<vector>
4 #include<string>
5 #include<map>
6 using namespace std;
7 int min_4(int a,int b,int c,int d)
8 {
9 a=a<b?a:b;
10 a=a<c?a:c;
11 a=a<d?a:d;
12 return a;
13 }
14 string work(int x)
15 {
16 string s="th";
17 const string ss[3]={"st","nd","rd"};
18 int t=x%10;
19 if(t==1&&x%100!=11)s=ss[0];
20 else if(t==2&&x%100!=12)s=ss[1];
21 else if(t==3&&x%100!=13)s=ss[2];
22 return s;
23 }
24 int main()
25 {
26 //freopen("acm.acm","r",stdin);
27 int n,len,i,t,m;
28 len=1;
29 int a[6000],x2=0,x3=0,x5=0,x7=0;
30 a[0]=1;
31 while(len <= 5846)
32 {
33 m=min_4(a[x2]*2,a[x3]*3,a[x5]*5,a[x7]*7);
34 if(m==a[x2]*2)x2++;
35 if(m==a[x3]*3)x3++;
36 if(m==a[x5]*5)x5++;
37 if(m==a[x7]*7)x7++;
38 a[len++]=m;
39 }
40 while(scanf("%d",&n))
41 {
42 if(!n)
43 break;
44 string s=work(n);
45 printf("The ");
46 printf("%d",n);
47 printf("%s",s.c_str());
48 printf(" humble number is ");
49 printf("%d",a[n-1]);
50 printf(".\n");
51 }
52 return 0;
53 }
54