var s:string;
a:mtype;
k,n,h:integer;
procedure zhuan(s:string);
var i:longint;
begin
for i:=1 to h do
case s[i] of
'0','1','2','3','4','5','6','7','8','9':a[i]:=ord(s[h-i+1])-48;
'a','b','c','d','f':a[i]:=ord(s[h-i+1])-86;
end;
end;
function check(a:mtype):boolean;
var i:integer;
begin
check:=true;
for i:=1 to h do
if a[i]<>a[h-i+1] then check:=false;
end;
procedure hui(var a:mtype);
var b:mtype; i:integer;
begin
for i:=1 to h do b[i]:=a[i];
for i:=1 to h do a[i]:=a[i]+b[h-i+1];
for i:=1 to h do
if a[i]>=k then
begin
a[i+1]:=a[i+1]+a[i] div k;
a[i]:=a[i] mod k;
end;
if a[h+1]<>0 then inc(h);
end;
begin
readln(k);
readln(s);
h:=length(s);
n:=0;
fillchar(a,sizeof(a),0);
zhuan(s);
while (n<=30)and(check(a)=false) do begin hui(a);inc(n); end;
if n>=30 then writeln('Impossible') else writeln(n);
end.
帮忙看看吧!!有一个数据总是过不去啊!!