#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 2123123123;
const int EPS = 1e-9;
inline void OPEN(const string &s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int x, y, a, b, l;
int main() {
  scanf("%d %d %d %d", &x, &y, &a, &b);
  l = x * y / gcd(x, y);
  printf("%d\n", b / l - (a - 1) / l);
}
