#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
const long long MAX_N = 100001;
bool exists[MAX_N];
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int main(int argc, char** argv) {
  unsigned long long x, y, a, b, val, num;
  cin >> x >> y >> a >> b;
  if (x < y) swap(x, y);
  val = x * y / gcd(x, y);
  unsigned long long t = (b - a) / val - 1;
  unsigned long long start, end;
  if (a % val == 0) {
    start = a;
  } else {
    start = val * (a / val + 1);
  }
  if (start > b) {
    num = 0;
  } else {
    num = t;
    end = start + t * val;
    while (end <= b) {
      num++;
      end += val;
    }
  }
  cout << num << endl;
  return 0;
}
