#include <bits/stdc++.h>
using namespace std;
long long gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main(void) {
  long long x, y, a, b;
  cin >> x >> y >> a >> b;
  long long g = gcd(x, y), k = x * y / g;
  cout << b / k - (a - 1) / k << endl;
  return 0;
}
