#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() {
  int x, y;
  long long int a, b;
  cin >> x >> y >> a >> b;
  int lcm = (x * y) / (gcd(x, y));
  int ans = (b / lcm) - ((a - 1) / lcm);
  cout << ans << endl;
  return 0;
}
