/* Team name: Omega
*  Problem name: Template
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
 
using namespace std;
 
#define SZ(a) int((a).size())
#define PB push_back
#define ALL(c) (c).begin(),(c).end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())
#define PRESENT(c,x) ((c).find(x) != (c).end())
#define CPRESENT(c,x) (find(all(c),x) != (c).end()) // present in a container or not.
#define MP make_pair
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define REP1(i,n) for(int _n=n, i=1;i<=_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<_b;++i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define FF first
#define SS second
#define INPUT(a) freopen (a, "r", stdin)
#define OUTPUT(a) freopen (a, "w", stdout)
#define FORD(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define FILL(a, v) memset(a, v, sizeof(a));
#define DREP(a)                 sort(ALL(a)); a.erase(unique(ALL(a)),a.end()) // will make the vector unique and sorted order
#define DEBUG(args...)          {dbg,args; cerr<<endl;}
#define INF                     (int)1e9
#define LINF                    (long long)1e18

typedef long long LL;
typedef long double LD;
typedef vector <int> VI;
typedef vector <LL> VLL;
typedef vector <double> VD;
typedef vector<string> VS;
typedef vector <VI> VVI;
typedef pair <int,int> PII;
typedef pair <LL,LL> PLL;
typedef vector <PII > VPII;
typedef pair <double, double> PDD;
typedef vector <PDD> VPDD;

struct debugger { template<typename T> debugger& operator , (const T& v) {  cerr<<v<<" ";    return *this;  } } dbg;

template<class T> string i2s(T x) {ostringstream o; o << x; return o.str(); }
VS splt(string s, char c = ' ') {VS rv; int p = 0, np; while (np = s.find(c, p), np >= 0) {if (np != p) rv.PB(s.substr(p, np - p)); p = np + 1;} if (p < SZ(s)) rv.PB(s.substr(p)); return rv;}

void print(VI v, int sz = -1) { if (sz == -1) sz = SZ(v); cerr << "["; if (sz) cerr << v[0]; FOR (i, 1, sz) cerr << ", " << v[i]; cerr << "]" << endl; }
void print(VD v, int sz = -1) { if (sz == -1) sz = SZ(v); cerr << "["; if (sz) cerr << v[0]; FOR (i, 1, sz) cerr << ", " << v[i]; cerr << "]" << endl; }
void print(VS v, int sz = -1) { if (sz == -1) sz = SZ(v); cerr << "["; if (sz) cerr << v[0]; FOR (i, 1, sz) cerr << ", " << v[i]; cerr << "]" << endl; }
void print (PII v) { cerr << "{ " << v.FF << ", " << v.SS << " }"; }
void print (VPII v, int sz = -1) { if (sz == -1) sz = SZ(v); cerr << "[ "; if (sz) print (v[0]); FOR (i, 1, sz) { cerr << ", "; print (v[i]);} cerr << "]" << endl;}
void print(VVI v, int sz1 = -1, int sz2 = -1) { if (sz1 == -1) sz1 = SZ(v); if (sz2 == -1) sz2 = SZ(v[0]); cerr << "[ ---" << endl;if (sz1) cerr << " ", print(v[0], sz2);FOR(i, 1, sz1) cerr << " ", print(v[i], sz2);    cerr << "--- ]\n";}

const double EPS = 1e-9;
const int MOD = int(1e9) + 7;
const double PI = acos(-1.0); //M_PI;
// Asy psyho says : Algo is more about pyschology and ability to stay focused during short amount of time.
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
//                                                                              Main Code Starts Now                                                                                        //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int gcd (int a, int b) {
    return b > 0 ? gcd (b, a % b) : a;
}

const int N = 794898;
bool prime[N + 5];
vector <vector <int > > divi (N + 5);
bool visited[N + 5];

void sieve () {
    FOR (i, 2, N + 1) {
        prime[i] = true;
    }
    for (int i = 2; i * i <= N; i++)
        if (prime[i]) {
            for (int j = i + i; j <= N; j += i) {
                prime[j] = false;
            }
        }
    for (int i = 2; i <= N; i++)
        if (prime [i])
            for (int j = i; j <= N; j += i) {
                if (SZ(divi[j]) == 0) 
                	divi[j].PB (i);
            }
}

int Ans[N];

int main() {
    sieve();
    
    vector <set<int> > st (N + 5);
    REP1 (i, N) {
        if (prime[i])
            for (int j = i; j <= N; j += i) {
                st[i].insert (j);
            }
    }
    
    VI a;
    a.PB (1);
    a.PB (2);
    visited[2] = true;
    
    set <int> :: iterator it;
    REP (i, N) {
        int num = a[SZ(a) - 1];
        int mn = N, pos = 0;
        REP (j, SZ(divi[num])) {
            int temp = divi[num][j];
            VI toRemove;
            int ok = false;
            for (it = st[temp].begin(); it != st[temp].end(); it++) {
                if (*it % temp == 0) {
                    if (visited[*it]) {
                        toRemove.PB (*it);
                    } else {
                        //toRemove.PB (*it);
                        //a.PB (*it);
                        ok = true;
                        if (*it < mn) {
                            mn = *it;
                            pos = temp;
                        }
                        //visited[*it] = true;
                        break;
                    }
                }               
            }   
            REP (k, SZ(toRemove)) {
                st[temp].erase (toRemove[k]);
            }
        }
        a.PB (mn);
        st[pos].erase (mn);
        visited[mn] = true;
    }
    
    
    
    REP (i, SZ(a)) {
        Ans[a[i]] = i + 1;
    }
    
    //cout << *max_element (Ans, Ans + 300000) << endl;
    
    //print (a, 25);
    
    int n;
    while (1) {
        scanf ("%d", &n);
        if (n == 0) break;
        printf ("The number %d appears in location %d.\n", n, Ans[n]);
    }
    

    
    return 0;
}