#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  if (x > y) swap(x, y);
  int r = gcd(x, y);
  int count = 0, mix = (x * y) / r, i = mix;
  bool in = false;
  if (mix == 1)
    cout << b - a + 1;
  else {
    for (i; i <= b; i += mix) {
      if (i >= a) {
        in = true;
        break;
      }
    }
    cout << (in ? ((b - i) / mix) + 1 : 0);
  }
}
