#include <bits/stdc++.h>
long long int gcd(long long int, long long int);
int main() {
  long long int x, y, a, b;
  scanf("%lli %lli %lli %lli", &x, &y, &a, &b);
  while (b % x != 0 || b % y != 0) {
    b--;
  }
  while (a % x != 0 || a % y != 0) {
    a++;
  }
  printf("%lli", (b - a) / ((x * y) / gcd(x, y)) + 1);
  return 0;
}
long long int gcd(long long int x, long long int y) {
  while (y != 0 && x != 0) {
    if (y < x) {
      x -= y;
    } else {
      y -= x;
    }
  }
  if (x == 0) {
    return y;
  } else {
    return x;
  }
}
