#include <bits/stdc++.h>
int gcd(int x, int y) { return x ? gcd(y % x, x) : y; }
int main() {
  int x, y, a, b, lcm;
  scanf("%d%d%d%d", &x, &y, &a, &b);
  lcm = x * y / gcd(x, y);
  printf("%d", b / lcm - (a - 1) / lcm);
  return 0;
}
