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