#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, a, b, tmp;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  cin >> n >> m >> a >> b;
  tmp = n * m / gcd(n, m);
  cout << b / tmp - (a - 1) / tmp;
  return 0;
}
