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