#include <bits/stdc++.h>
using namespace std;
long long x, y, a, b;
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main() {
  long long nok;
  long long l, r;
  scanf("%I64d %I64d %I64d %I64d", &x, &y, &a, &b);
  nok = (x * y) / gcd(x, y);
  r = b / nok;
  l = a / nok;
  if (a % nok != 0) {
    l++;
  }
  printf("%I64d\n", r - l + 1);
  return 0;
}
