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