#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, g = 0, sum = 0, t, p;
  cin >> a >> b >> c >> d;
  for (int i = 1; i <= a && i <= b; i++) {
    if (a % i == 0 && b % i == 0) {
      g = i;
    }
  }
  int l = (a * b) / g;
  t = d / l;
  p = c / l;
  if (p > 0 && c % l == 0) p = p - 1;
  sum = t - p;
  cout << sum;
}
