#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
int addm(int& a, int b) { return (a += b) < mod ? a : a -= mod; }
template <class T, class U>
bool smin(T& a, U b) {
  return a > b ? (a = b, 1) : 0;
}
template <class T, class U>
bool smax(T& a, U b) {
  return a < b ? (a = b, 1) : 0;
}
int L, n, p, t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int M = 0, Mb = 0;
  priority_queue<pair<int, int> > pq;
  cin >> L >> n >> p >> t;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    if (r - l < p) continue;
    int cM, cx;
    while (!pq.empty() && -pq.top().first <= l) {
      pair<int, int> kk = pq.top();
      pq.pop();
      Mb = max(kk.second, Mb);
    }
    cM = Mb + (r - l) / p;
    cx = l + (r - l) / p * p;
    while (!pq.empty() && -pq.top().first <= r) {
      pair<int, int> kk = pq.top();
      pq.pop();
      Mb = max(kk.second, Mb);
      int ncan = (r + kk.first) / p;
      int nM = ncan + kk.second;
      int nx = -kk.first + ncan * p;
      if (nM > cM || (nM == cM && nx < cx)) {
        cM = nM;
        cx = nx;
      }
    }
    pq.push({-cx - t, cM});
    M = max(M, cM);
  }
  cout << M << endl;
}
