#include <stdio.h>
#include <stdlib.h>
int N;
long long ReverseN(long long x)
{
int y = 0;
while (x > 0)
{
y *= N;
y += x % N;
x /= N;
}
return y;
}
long long PlusN(long long a, long long b)
{
int c = 0, t = 0, w = 1;
while (a > 0 || b > 0 || t > 0)
{
int i = a % N, j = b % N;
c += (i + j + t) % N * w;
t = (i + j + t) / N;
a /= N, b /= N;
w *= N;
}
return c;
}
int main(void)
{
char digits[100];
scanf("%d%s", &N, digits);
long long M = strtoll(digits, NULL, N);
int s = 0;
while (M != ReverseN(M))
{
M = PlusN(M, ReverseN(M));
s++;
if (s > 30)
{
printf("Impossible!");
return 0;
}
}
printf("STEP=%d", s);
return 0;
}