#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int powmod(long long int a, long long int b) {
  long long int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
};
int main() {
  int t = 1;
  while (t--) {
    long long int x, y, a, b, c, d;
    cin >> x >> y >> a >> b;
    c = x * y / (gcd(max(x, y), min(x, y)));
    d = a % c;
    if (d != 0) a += c - d;
    d = b % c;
    if (d != 0) b -= d;
    if (a <= b)
      cout << ((b - a) / c) + 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
