#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
using namespace std;
const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647,
          ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567,
          ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
void fre() {
  freopen("/Users/luras/Desktop/in.txt", "r", stdin);
  freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;
long long a1, b1, a2, b2, L, R;
long long solve() {
  gmax(L, b1);
  gmax(L, b2);
  if (a1 < a2) {
    swap(a1, a2);
    swap(b1, b2);
  }
  long long ans = 0;
  long long k = max((long long)0, (L - b1) / a1);
  long long x = k * a1 + b1;
  if (x < L) x += a1;
  if (a1 >= 1000) {
    if (x > R) return 0;
    for (long long i = x; i <= R; i += a1) {
      long long tmp = (i - b2) / a2;
      if ((i - b2) % a2 == 0 && tmp >= 0) ans++;
    }
    return ans;
  } else {
    if (x > R) return 0;
    vector<long long> vt;
    vt.clear();
    for (long long i = x; i <= min(R, x + (long long)2e6); i += a1) {
      long long tmp = (i - b2) / a2;
      if ((i - b2) % a2 == 0 && tmp >= 0) vt.push_back(i);
    }
    if (vt.size() < 2) return vt.size();
    long long t = vt[1] - vt[0];
    ans = (R - vt[0]) / t + 1;
    return ans;
  }
}
int main() {
  while (~scanf("%lld%lld%lld%lld%lld%lld", &a1, &b1, &a2, &b2, &L, &R)) {
    printf("%lld\n", solve());
  }
  return 0;
}
