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