#include <bits/stdc++.h>
using namespace std;
string s;
int el[10001];
long long x, y, a, b, q, d, k, c;
int main() {
  q = 0;
  cin >> x >> y >> a >> b;
  if (x == y) {
    if (a % x == 0) ++q;
    q += b / x - a / x;
    cout << q << endl;
  } else {
    c = x;
    d = y;
    while (d) {
      c %= d;
      swap(c, d);
    }
    k = x / c * y;
    if (a % k == 0) ++q;
    q += b / k - a / k;
    cout << q << endl;
  }
  return 0;
}
