#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return (x * y) / gcd(x, y); }
int main() {
  int x, y, a, b, lc;
  cin >> x >> y >> a >> b;
  lc = lcm(x, y);
  cout << (b / lc) - ((a - 1) / lc) << endl;
  return 0;
}
