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