#include <bits/stdc++.h>
using namespace std;
int GCDFast(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int GCD(int b, int a) {
  if (a == 0) return b;
  return GCD(a, b % a);
}
int a[100005], totalCoin;
long long minimium = 1000005;
int minCoin = 0;
int main() {
  long long i, n, m, x, testCase = 0, j, k, y;
  long long sum, max, number, N, min;
  string str1, str2, str[105];
  char ch1, ch2;
  long long l, r, p, q;
  int check[10];
  while (cin >> x >> y >> p >> q) {
    r = GCD(x, y);
    l = x * y / r;
    number = 0;
    for (i = p; i <= q; i++) {
      if (i % l == 0) {
        x = q - i;
        number = x / l + 1;
        break;
      }
    }
    cout << number << "\n";
  }
  return 0;
}
