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