#include <bits/stdc++.h>
int main() {
  int x, y, a, b, max, min, res, lcd, p;
  scanf("%d %d %d %d", &x, &y, &a, &b);
  if (x >= y) {
    max = x;
    min = y;
  } else {
    max = y;
    min = x;
  }
  p = max;
  while (max % min != 0) {
    max = max + p;
  }
  lcd = max;
  if (lcd >= a) {
    res = b / lcd;
  } else {
    if (a % lcd != 0) {
      res = b / lcd - a / lcd;
    } else {
      res = b / lcd - a / lcd + 1;
    }
  }
  printf("%d", res);
  return 0;
}
