#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
void debugarr(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
void debugvec(vector<int> arr) {
  cout << "[";
  for (int i = 0; i < ((int)(arr.size())); i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  int x, y, a, b;
  scanf("%d", &x);
  scanf("%d", &y);
  scanf("%d", &a);
  scanf("%d", &b);
  long long z = (((long long)x) * y) / gcd(x, y);
  cout << b / z - (a - 1) / z << endl;
  return 0;
}
