#include <bits/stdc++.h>
using namespace std;
long int gcd(long int a, long int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  long int x, y, a, b, n, ans;
  cin >> x >> y >> a >> b;
  n = x * y / gcd(x, y);
  ans = b / n;
  if (a % n == 0)
    ans -= a / n - 1;
  else
    ans -= a / n;
  cout << ans << endl;
  return 0;
}
