#include <bits/stdc++.h>
using namespace std;
int lcm(int a, int b) {
  int max = (a >= b ? a : b), min = (a < b ? a : b), i;
  for (i = 1;; ++i) {
    if ((max * i) % min == 0) {
      return (max * i);
    }
  }
}
int main() {
  long long n, m, a, b, s = 0;
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &a, &b);
  s = b / lcm(n, m) - (a - 1) / lcm(n, m);
  printf("%I64d", s);
  return 0;
}
