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