#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
int L, n, p, t;
int dp[MAXN], ds[MAXN];
void solve() {
  read(L);
  read(n);
  read(p);
  read(t);
  ds[0] = -t;
  for (int i = 1, j = 1, l, r; i <= n; ++i) {
    read(l);
    read(r);
    dp[i] = dp[i - 1];
    ds[i] = ds[i - 1];
    for (--j; j < i && ds[j] + t <= r; ++j) {
      int st = max(ds[j] + t, l), cnt = (r - st) / p;
      int w1 = dp[j] + cnt, w2 = st + cnt * p;
      if (w1 > dp[i] || (w1 == dp[i] && w2 < ds[i])) {
        dp[i] = w1;
        ds[i] = w2;
      }
    }
  }
  printf("%d\n", dp[n]);
}
int main() {
  solve();
  return 0;
}
