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