#include <cstdio>
#define ll long long
using namespace std;
ll A, B, st1, st2, l, x, y, d, a, b, dd, flag;
void g(ll a, ll b, ll &x, ll &y) {
if (!b) {
if (A % a != 0)
flag = 1;
else
B = A / a, st2 = st2 / a, x = 1, y = 0;
return;
}
g(b, a % b, y, x);
if (flag)
return;
y = y - a / b * x;
}
int main() {
scanf("%lld%lld%lld%lld%lld", &A, &B, &st1, &st2, &l);
st1 = (st1 - st2 + l) % l, st2 = l;
A = (B - A + st2) % st2;
g(st1, st2, x, y);
x = (B * x % st2 + st2) % st2;
if (flag)
printf("Impossible");
else
printf("%lld", x);
return 0;
}