#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  for (;;) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
int main() {
  int x, y;
  long long a, b, l, temp1, temp2, rem, ans, m;
  cin >> x >> y >> a >> b;
  l = x * y;
  m = gcd(x, y);
  l = l / m;
  temp1 = a / l;
  rem = a % l;
  temp2 = b / l;
  ans = temp2 - temp1;
  if (rem == 0) {
    ans++;
  }
  cout << ans;
  return 0;
}
