#include <bits/stdc++.h>
using namespace std;
int LCD(int a, int b) {
  if (a > b) swap(a, b);
  int c = b;
  while (1) {
    if (c % a == 0 && c % b == 0) break;
    c += b;
  }
  return c;
}
int main() {
  int x, y, a, b, z;
  cin >> x >> y >> a >> b;
  z = LCD(x, y);
  cout << b / z - (a - 1) / z << endl;
  return 0;
}
