#include <bits/stdc++.h>
long long x, y, a, b;
int main() {
  scanf("%d%d%d%d", &x, &y, &a, &b);
  int ta, tb;
  for (ta = x, tb = y; ta % tb != 0;) {
    ta %= tb;
    int t = ta;
    ta = tb;
    tb = t;
  }
  int k = tb;
  k = x * y / k;
  int sum = 0;
  int i = a;
  if (a % k != 0) {
    int temp = a / k;
    temp++;
    i = temp * k;
  }
  if (i <= b) {
    int end = b;
    if (b % k != 0) {
      int t = b / k;
      t *= k;
      end = t;
    }
    sum = (end - i) / k + 1;
  }
  printf("%d\n", sum);
}
