dic={'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,\
'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
dic2={0:'0',1:'1',2:'2',3:'3',4:'4',5:'5',6:'6',7:'7',8:'8',9:'9',\
10:'A',11:'B',12:'C',13:'D',14:'E',15:'F'}
def reverse(x):
i=len(x)-1
y=''
while i>=0:
y+=x[i]
i-=1
return y
def add(n,x):
y=reverse(x)
z=0
i=0
length=len(x)
while(i<length):
z*=n
z+=(dic[x[i]]+dic[y[i]])
i+=1
_z=''
while(z!=0):
_z+=dic2[z%n]
z//=n
return reverse(_z)
def isPalindromic(z):
z2=reverse(z)
length=len(z)
i=0
while(i<length):
if z[i]!=z2[i]:
return False
i+=1
return True
n=int(input())
x=input()
z=add(n,x)
idx=1
isImpossible=True
while isPalindromic(z)==False:
if idx>30:
isImpossible=False
break
z=add(n,z)
idx+=1
if isImpossible==True:
print('STEP={}'.format(idx))
else:
print("Impossible!")