#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long a, b, x, y, c = 0;
  cin >> x >> y >> a >> b;
  int g = (x * y) / gcd(x, y);
  cout << b / g - (a - 1) / g << endl;
  return 0;
}
