#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long getans(long long n, long long k) {
  long long ans = n / k;
  return ans;
}
int main() {
  long long x, y, a, b;
  while (~scanf("%I64d%I64d%I64d%I64d", &x, &y, &a, &b)) {
    long long ans;
    ans = getans(b, (long long)x * y / gcd(x, y)) -
          getans(a, (long long)x * y / gcd(x, y));
    if (a % ((long long)x * y / gcd(x, y)) == 0) ans++;
    printf("%I64d\n", ans);
  }
  return 0;
}
