#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int x, y, a, b;
  std::cin >> x >> y >> a >> b;
  int k = x * y / gcd(x, y);
  int lo = (a + k - 1) / k;
  int hi = b / k;
  std::cout << hi - lo + 1 << '\n';
}
