#include <bits/stdc++.h>
typedef long long LL;
const double INF = 1e100;
const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double EPS = 1e-8;
const int MAXN = 100033;
int x, y, a, b;
int c, s;
inline int gcd(int x, int y) {
  if (y) return gcd(y, x % y);
  return x;
}
int main() {
  scanf("%d%d%d%d", &x, &y, &a, &b);
  c = x * y / gcd(x, y);
  printf("%d\n", b / (c) - (a - 1) / (c));
  return 0;
}
