#include <bits/stdc++.h>
int x, y, a, b, t, ans;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int cal(int n) { return n / t; }
int main() {
  while (scanf("%d%d%d%d", &x, &y, &a, &b) != EOF) {
    t = x * y / gcd(x, y);
    ans = 0;
    ans = cal(b) - cal(a - 1);
    printf("%d\n", ans);
  }
  return 0;
}
