#include <bits/stdc++.h>
using namespace std;
int nod(int a, int b) {
  int c;
  if (a > b) swap(a, b);
  for (;;) {
    c = b % a;
    b = a;
    a = c;
    if (a == 0) return b;
  }
}
int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;
  int d = x * y / nod(x, y);
  int c = b / d - (a - 1) / d;
  if (c < 0) c = 0;
  cout << c;
  return 0;
}
