#include <bits/stdc++.h>
using namespace std;
int gcd(int m, int n) {
  if (!m || !n) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}
int lcm(int m, int n) {
  if (!m || !n) return 0;
  return ((m / gcd(m, n)) * n);
}
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  int l = lcm(x, y), res;
  res = b / l - (a - 1) / l;
  cout << res << endl;
  return 0;
}
