#include <bits/stdc++.h>
using namespace std;
int gcd(int &x, int &y) {
  int pom;
  while (y) {
    pom = y;
    y = x % y;
    x = pom;
  }
  return x;
}
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  long long int lcm = x * y;
  lcm = lcm / gcd(x, y);
  int range_a = --a / lcm;
  int range_b = b / lcm;
  cout << range_b - range_a;
  return 0;
}
