#include <bits/stdc++.h>
using namespace std;
int gcdr(long long int a, long long int b) {
  if (a == 0) return b;
  return gcdr(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcdr(a, b);
}
int main() {
  long long x, y, a, b, ans = 0, i, z, j, k;
  cin >> x >> y >> a >> b;
  i = a;
  while (i) {
    if (i % lcm(x, y) == 0) {
      j = i;
      break;
    }
    i++;
  }
  i = b;
  while (i) {
    if (i % lcm(x, y) == 0) {
      k = i;
      break;
    }
    i--;
  }
  ans = 1 + (k - j) / lcm(x, y);
  cout << ans;
  return 0;
}
