#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<map> #include <algorithm> #define mod 1000000007 using namespace std; typedef long long ll;
void exgcd(ll a , ll b , ll &c , ll &x , ll &y) { if (!b){x=1;y=0;c=a;} else{exgcd(b,a%b,c,y,x);y-=a/b*x;} }
int main() { ll a,b,c,x1,x2,y1,y2,t,x,y,d; while (~scanf("%I64d%I64d%I64d",&a,&b,&c)) { ll ans = 0; scanf("%I64d%I64d",&x1,&x2); scanf("%I64d%I64d",&y1,&y2); c = -c; if (c<0) { a = - a ; b = - b ; c = - c ; } if (a<0) { a = - a; t = - x1; x1 = - x2; x2 = t; } if (b<0) { b= - b; t = - y1; y1 = -y2; y2 = t; } if (a==0&&b==0&&c!=0) ans = 0; else if (a==0&&b==0&&c==0) ans = (x2-x1+1)*(y2-y1+1); else if (a==0) { if (c%b||c/b<y1||c/b>y2) ans = 0; else ans = x2 - x1 + 1; } else if (b==0) { if (c%a||c/a<x1||c/a>x2) ans = 0; else ans = y2 - y1 + 1; } else { exgcd(a,b,d,x,y); //cout<<"now d = "<<d<<endl; //cout<<"x = "<<x<<" y = "<<y<<endl; if (c%d) ans = 0; else { //cout<<"a b c = "<<a<<" "<<b<<" "<<c<<endl; a /= d; b /= d; c /= d; x *= c; y *= c;
ll l,r,lx,ly,rx,ry; lx = ceil((x1 *1.0- x)/b); ly = ceil((y- y2 *1.0)/a); l = max(lx,ly); rx = floor((x2 *1.0- x)/b); ry = floor((y - y1 *1.0)/a); r = min(rx,ry); if (r<l) ans = 0; else ans = r - l + 1; } } printf("%lld\n",ans);