#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int lcm(int x, int y) { return x * y / gcd(x, y); }
int main() {
  int a, b, x, y;
  cin >> x >> y >> a >> b;
  int t = lcm(x, y);
  cout << b / t - (a - 1) / t << endl;
}
