#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
vector<int> decomp(int n) {
  int p = 1;
  int d = 2;
  vector<int> D;
  while (n != 1) {
    while (n % d == 0) {
      p *= d;
      n = n / d;
    }
    if (p != 1) {
      D.push_back(p);
      p = 1;
    }
    ++d;
  }
  return D;
}
int main() {
  int l, r, x, y;
  while (cin >> l >> r >> x >> y) {
    if (y % x != 0)
      cout << 0 << endl;
    else {
      l = (l + x - 1) / x;
      r = r / x;
      vector<int> D = decomp(y / x);
      int k = D.size();
      int y = 1;
      for (int i = 0; i < k; ++i) y *= D[i];
      queue<int> q;
      vector<pair<int, int>> dp(1 << k, pii(0, 0));
      dp[0] = pii(1, y);
      q.push(0);
      int c = 0;
      while (not q.empty()) {
        int bm = q.front();
        q.pop();
        if ((dp[bm].first >= l) and (dp[bm].first <= r) and
            (dp[bm].second >= l) and (dp[bm].second <= r)) {
          ++c;
        }
        for (int i = 0; i < k; ++i) {
          if ((not(bm & (1 << i))) and dp[bm + (1 << i)].first == 0) {
            q.push(bm + (1 << i));
            dp[bm + (1 << i)] = pii(dp[bm].first * D[i], dp[bm].second / D[i]);
          }
        }
      }
      cout << c << endl;
    }
  }
}
