#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
char c[100000] = { 0 };
int main()
{
int N, M;
int step = 1;
int i, j, k=0, n;
int flag = 0;
int sum, t = 0, t1, t2, t3 = 0, t4;
int Record[1000] = { 0 }, Mid[1000] = { 0 };
scanf("%d", &N);
if (N > 10 && N != 16) {
printf("No!!!");
return 0;
}
scanf("%s", c);
while (step < 30) {
flag = 0; n = 0;
t2 = 0, sum = 0;
t4 = 0; i = 0;
if (step == 1) {
while ((c[i] != 0)) {
if (c[i] <= 57 && c[i] >= 48) {
Mid[i] = c[i] - 48;
}
else {
if (c[i] >= 65 && c[i] <= 70) {
Mid[i] = c[i] - 55;
}
}
i++;
}
n = i;
for (i = 0; i < n; i++) {
t2 += Mid[i] * pow(N, (double)(n - i - 1));
}
for (i = 0; i < n; i++) {
t4 += Mid[i] * pow(N, (double)(i));
}
}
else {
for (i = 0; i <= k; i++) {
t2 += Record[i] * pow(N, (double)(k - i));
}
for (i = 0; i <= k; i++) {
t4 += Record[i] * pow(N, (double)(i));
}
}
t3 = t2 + t4;
k = 0;
while (t3) {
Record[k] = t3 % N;
t3 /= N;
k++;
}
k--;
for (i = 0; i <= k; i++) {
if (Record[i] != Record[k - i]) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("STEP=%d", step);
break;
}
step++;
}
if (flag == 1) {
printf("Impossible!");
}
}