#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
string m,d;
string gjdjf(string a,string b)
{
string d;
if (a.length() > b.length())
{
int c;
c = a.length() - b.length();
for (int i = 0; i < c; i++)
{
b = "0" + b;
}
}
if (a.length() < b.length())
{
int c;
c = b.length() - a.length();
for (int i = 0; i < c; i++)
{
a = "0" + a;
}
}
int x = 0;
for (int i = a.length() - 1; i >= 0; i--)
{
if (a[i] - '0' + b[i] - '0' + x > n-1)
{
d = (char)(a[i] + b[i] - '0' - n + x) + d;
x = 1;
}
else
{
d = (char)(a[i] + b[i] - '0' + x) + d;
x = 0;
}
}
if (x == 1)
{
d = '1' + d;
}
return d;
}
bool hw(string a)
{
d = a;
reverse(a.begin(), a.end());
return (a == d);
}
int main()
{
cin >> n>>m;
for (int i = 0; i < m.length(); i++) {
if (m[i] >= 'A' && m[i] <= 'Z')m[i] = m[i] - 'A' + 10 + '0';
}
for (int i = 1; i <= 31; i++)
{
if (i==31)
{
cout << "Impossible!";
break;
}
if (hw(m))
{
cout << "STEP=" << i;
break;
}
d = m;
reverse(d.begin(), d.end());
m = gjdjf(m, d);
}
return 0;
}
大家救救本蒟蒻吧!!!