var
qwq:boolean;
x,y,n,m,l,i:longint;
begin
assign(input,'poj_hama.in');reset(input);
assign(output,'poj_hama.out');rewrite(output);
qwq:=false;
readln(x,y,m,n,l);
x:=x mod l ;y:=y mod l;m:=m mod l;n:=n mod l;
while x<>y do
begin
inc(i);
inc(x,m);x:=x mod l;
inc(y,n);y:=y mod l;
if i>1000000 then
begin
qwq:=true;
break;
end;
end;
if qwq then writeln('Impossible')
else
writeln(i);
close(input);close(output);
end.