#include <bits/stdc++.h>
using namespace std;
long long int hcf(long long int a, long long int b) {
  if (a == b) {
    return a;
  } else if (a > b) {
    return hcf(a - b, b);
  } else {
    return hcf(a, b - a);
  }
}
long long int lcm(long long int a, long long int b) {
  return a * b / hcf(a, b);
}
int main() {
  long long int x, y, a, b, pos1 = 0, pos2 = 0, c, opt = 0;
  cin >> x >> y >> a >> b;
  c = lcm(x, y);
  pos1 = (a - 1) / c;
  pos2 = b / c;
  opt = pos2 - pos1;
  cout << opt;
  return 0;
}
