#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  int ct = 0;
  int diff = (x * y) / gcd(x, y);
  int i = a;
  while (i <= b) {
    if (i % x == 0 && i % y == 0) {
      ct++;
      break;
    }
    i++;
  }
  ct += (b - i) / diff;
  cout << ct;
}
