include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int a[100],b[100],n;
void init(int x[]){
char s[100];
cin>>s;
x[0]=strlen(s);
for(int i=1;i<=x[0];i){
if(s[x[0]-i]>=‘0’&&s[x[0]-i]<=‘9’)
a[i]=s[x[0]-i]-‘0’;
else
a[i]=s[x[0]-i]-‘A’+10;
}
}
bool ishws(int a[]){
for(int i=1;i<=a[0]/2;i){
if(a[i]!=a[a[0]-i+1])
return false;
}
return true;
}
void add(int a[]){
for(int i=1;i<=a[0];i) b[i]=a[a[0]-i+1];
for(int i=1;i<=a[0];i) a[i]+=b[i];
for(int i=1;i<=a[0];i){
a[i+1]+=a[i]/n;
a[i]%=n;
}
if(a[a[0]+1]>0) a[0];
}
int main(){
cin>>n;
init(a);
if(ishws(a)){
cout<<0<<endl;
return 0;
}
int bs=1;
while(bs<=30){
add(a);
if(ishws(a)){
cout<<bs<<endl;
return 0;
}
bs++;
}
cout<<”Impossible”<<endl;
return 0;
}
markdown2333