#include "bits/stdc++.h"usingnamespacestd;
bool Check (conststring & s) {
string t = s;
reverse_copy(s.begin(), s.end(), t.begin());
return s == t;
}
void Update(string & s, int n) {
string t = s;
reverse_copy(s.begin(), s.end(), t.begin());
int u = 0;
for (int i = s.size() - 1; i >= 0; --i) {
int res = u;
if (isdigit(s[i])) res += s[i] - '0';
else res += s[i] -'A' + 10;
if (isdigit(t[i])) res += t[i] - '0';
else res += t[i] - 'A' + 10;
u = res / n; res %= n;
if (res < 10) s[i] = '0' + res;
else s[i] = 'A' + res - 10;
}
if (u > 10) { s = "A" + s; s[0] += u - 10; }
elseif (u > 0) { s = "0" + s; s[0] += u; }
}
int main() {
int n, times;
string m;
cin >> n >> m;
for (times = 0; times <= 30; ++times) {
if (Check(m)) { cout << "STEP=" << times; break; }
Update(m, n);
}
if (times > 30) cout << "Impossible!";
return0;
}