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