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