#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 * 1000 + 10, INF = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b > a) swap(a, b);
  while (b != 0) {
    long long tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
  ios::sync_with_stdio(false);
  long long x, y, a, b;
  cin >> x >> y >> a >> b;
  long long l = lcm(x, y);
  cout << (b / l) - ((a - 1) / l) << endl;
  return 0;
}
