#include <stdio.h>
typedef __int64 LL;
LL extgcd(LL a,LL b,LL &x,LL &y)
{
if(!b)
{
x = 1;
y = 0;
return a;
}
LL g = extgcd(b,a%b,x,y);
LL t = x;
x = y;
y = t - (a / b) * y;
return g;
}
inline LL _abs(__int64 x)
{
return x > 0 ? x : -x;
}
bool modeq(LL a,LL c,LL m,LL &x)
{
LL g,y;
g = extgcd(a,m,x,y);
if( c%g )
return false;
else
{
x = (c/g * x) % m;
x %= _abs(m/g);
if(x<0) x += _abs(m/g);
return true;
}
}
int main()
{
LL x,y,m,n,L;
LL A,C,M,X0;
while(scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&L)!=EOF)
{
A = m-n;
C = y-x;
M = L;
if(modeq(A,C,M,X0)) printf("%I64d\n",X0);
else printf("Impossible\n");
}
return 0;
}