#include <bits/stdc++.h>
using namespace std;
double mini(double l, double r) {
  if (l < r)
    return l;
  else
    return r;
}
int main() {
  long long x, y, a, b;
  while (cin >> x >> y >> a >> b) {
    int ia = a + x - (a % x);
    int ib = b + y - (b % y);
    if (a % x == 0) ia = a;
    if (b % y == 0) ib = b;
    long long dif;
    bool is = false;
    bool ishold = false;
    int hold;
    for (int i = ia; i <= b; i += x) {
      if (i % y == 0) {
        if (is == true) {
          dif = i - hold;
          ishold = true;
          break;
        }
        hold = i;
        is = true;
      }
    }
    long long ans;
    if (is == false) {
      cout << 0 << endl;
      continue;
    }
    if (ishold == false) {
      cout << 1 << endl;
      continue;
    }
    ans = (b) / (dif);
    cout << (b / dif) - ((a - 1) / dif) << endl;
  }
  return 0;
}
