#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main(int argc, char* argv[]) {
  unsigned long long x, y, a, b;
  cin >> x >> y >> a >> b;
  unsigned long long g = gcd(x, y), s = x / g * y, st = a - a % s, r = 0;
  if (a % s) st += s;
  cout << (b < st ? 0 : (b - st) / s + 1) << endl;
  return 0;
}
