#include <bits/stdc++.h>
int ucln(int a, int b) {
  int r;
  while (b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
using namespace std;
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  int i = a, j = b;
  int n = x * y / ucln(x, y);
  while (i % n != 0) i++;
  while (j % n != 0) j--;
  if (i >= a && i <= b && j >= a && j <= b && i <= j) cout << (j - i) / n + 1;
  if ((a == b && a % n != 0) || (n > b)) cout << 0;
}
