#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<sstream>
typedef long long LL;
using std::cin;
using std::cout;
using std::string;
void Test()
{
freopen("temp\\in.txt", "r", stdin);
}
int n, N;
string s, model;
void Input()
{
cin.ignore(6);
cin>>s;
}
int ToNum(string t)
{
int x, ret;
for(int i=1; i<=n; i++)
{
std::stringstream(t)>>x;
int t = 1;
for(int j=1; j<=i; j++)
t*=x;
ret += t;
}
return ret;
}
string ToStr(int x)
{
string ret;
while(x)
{
int t = x%n;
ret = ret+"."+std::to_string(t);
x/=n;
}
return ret;
}
int Check(int num)
{
cout<<"FETCH "+ToStr(num)<<std::endl;
Input();
if(s < model)
return -1;
if(s > model)
return 1;
if(s == model)
return 0;
}
int main()
{
// Test();
scanf("SIZE %d\n", &n);
N = 1;
for(int i=1; i<=n; i++)
N*=n;
Input();
model = s;
int L, R;
// find left
int l=1, r=N;
while(l<r)
{
int mid = (l+r)/2;
if(Check(mid) == -1)
l=mid+1;
else
r=mid;
}
L = l;
// find right
int l=1, r=N;
while(l<r)
{
int mid = (l+r)/2;
if(Check(mid) != 1)
l=mid+1;
else
r=mid;
}
R = l-1;
printf("%d", R-L);
return 0;
}