#include <bits/stdc++.h>
using namespace std;
void gcd(long long a, long long b, long long &d, long long &x, long long &y);
int main() {
  long long a1, b1, a2, b2, L, R, k, l, d, temp1, temp2;
  long long ans = 0;
  long double q, p;
  cin >> a1 >> b1 >> a2 >> b2 >> L >> R;
  L = max(b2, L);
  if (L > R)
    cout << "0" << endl;
  else {
    gcd(a1, a2, d, k, l);
    l = -l;
    temp1 = a1 / d;
    temp2 = abs(a2 / d);
    if ((b2 - b1) % d != 0) {
      cout << "0" << endl;
      return 0;
    }
    k *= (b2 - b1) / d;
    l *= (b2 - b1) / d;
    q = (long double)(L - b1) / a1;
    p = (long double)(R - b1) / a1;
    q = max((long double)0, q);
    if (q > p) {
      cout << "0" << endl;
      return 0;
    }
    ans += (long long)(p - k) / temp2 - (long long)(q - k) / temp2;
    if (k <= q && (long long)(q - k) % temp2 == 0 &&
        ((q - k) - (long long)(q - k)) <= 1e-10)
      ans++;
    else if (k >= p && (long long)(k - p) % temp2 == 0 &&
             ((k - p) - (long long)(k - p)) <= 1e-10)
      ans++;
    else if (k > q && k < p)
      ans++;
    cout << ans << endl;
  }
  return 0;
}
void gcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (b == 0) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
