#include <bits/stdc++.h>
int hcf(int, int);
int x, y;
long a, b;
int main() {
  int i;
  scanf("%d%d%ld%ld", &x, &y, &a, &b);
  int lcm, count = 0;
  lcm = (x * y) / hcf(x, y);
  long z;
  if (a % lcm == 0)
    z = (a / lcm) - 1;
  else
    z = (a / lcm);
  count = (b / lcm) - z;
  printf("%d\n", count);
  return 0;
}
int hcf(int p, int q) {
  if (p == q)
    return p;
  else if (p > q)
    hcf(p - q, q);
  else
    hcf(p, q - p);
}
