#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios_base::sync_with_stdio(false);
  long long a1, b1, a2, b2, l, r, i, ans = 0, k, c, var, x, y, z, q;
  cin >> a1 >> b1 >> a2 >> b2 >> l >> r;
  x = (a1 * a2);
  y = gcd((a1), (a2));
  z = x / y;
  q = z;
  if (a1 > a2) {
    k = a1;
    c = b1;
    x = a2;
    y = b2;
  } else {
    k = a2;
    c = b2;
    x = a1;
    y = b1;
  }
  if (r >= c && r >= y) {
    var = ((l - c) / k) * k + c;
    if (var < l) var += k;
    if (var < c) var = c;
    if (var < y) {
      var += ((y - var) / k) * k;
      if (var < y) var += k;
    }
    z = z + var;
    while (var <= r && (var - y) % x != 0) {
      var += k;
      if (var > z) break;
    }
    if (var > r || var > z)
      ans = 0;
    else
      ans += (r - var) / q + 1;
  } else
    ans = 0;
  cout << ans << endl;
}
