#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int f[MAXN], g[MAXN];
int main() {
  int L, n, p, t;
  scanf("%d%d%d%d", &L, &n, &p, &t);
  f[0] = 0, g[0] = -t;
  for (int i = 1, j = 1; i <= n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    f[i] = f[i - 1], g[i] = g[i - 1];
    for (--j; j < i && g[j] + t <= r; ++j) {
      int lx = max(l, g[j] + t), cnt = f[j] + (r - lx) / p,
          z = r - (r - lx) % p;
      if (cnt > f[i] || (cnt == f[i] && z < g[i])) f[i] = cnt, g[i] = z;
    }
  }
  printf("%d\n", f[n]);
  return 0;
}
