#include<iostream>
using namespace std;
int n;
char s[200];
int a[200],b[200];
int cnt, lens, cur;
bool check()
{
for (int i = lens+1 - 1; i > 0; i--)
{
if (a[i]!=a[lens +1-i])
{
return false;
}
}
return true;
}
void add()
{
for (int i = 1; i <= lens; i++)
{
b[i] = a[lens + 1 - i];
}
cur = 1;
for (int i = 1; i <= lens; i++)
{
a[i] += b[i];
if (a[i]>=n)
{
a[i] -= n;
a[i + 1]++;
}
cur++;
}
if (a[cur] == 0 && cur > 1) cur--;
lens = cur;
}
int main() {
cin >> n;
cin >> s;
lens = strlen(s);
int flage = 1;
for (int i = 0; i < lens; i++)
{
if (s[i]!=s[lens-1-i]) flage = 0;
}
if (flage)
{
cout << "STEP=0"; return 0;
}
for (int i = 0; i < lens; i++)
{
a[lens - i] = s[i] - 48;
}
while (!check())
{
cnt++;
add();
if (cnt>30)
{
cout << "Impossible!"; return 0;
}
}
cout << "STEP=" << cnt;
return 0;
}