#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1.0);
int cs = 1, test;
int gcd(int a, int b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
int main() {
  int n, m, i, j, k, a, b, t, x, y, z, ans = 0, len, count = 0, flag = 0, tmp,
                                       mx = -1, p, q, sum;
  scanf("%d %d", &x, &y);
  scanf("%d %d", &a, &b);
  z = gcd(x, y);
  z = x * y / z;
  a--;
  p = a / z;
  q = b / z;
  ans = q - p;
  printf("%d\n", ans);
  return 0;
}
