#include <bits/stdc++.h>
using namespace std;
int l, n, p, t, i, j, x, y, v, L, f[100001], g[100001];
int main() {
  scanf("%d%d%d%d\n", &l, &n, &p, &t);
  g[0] = -t;
  for (i = j = 1; i <= n; i++) {
    scanf("%d%d\n", &x, &y);
    j--;
    for (; j < i && g[j] + t <= y; j++) {
      L = max(x, g[j] + t);
      v = (y - L) / p + f[j];
      if (v > f[i] || (v == f[i] && L + (y - L) / p * p < g[i]))
        f[i] = v, g[i] = L + (y - L) / p * p;
    }
    if (f[i - 1] > f[i] || (f[i - 1] == f[i] && g[i - 1] < g[i]))
      f[i] = f[i - 1], g[i] = g[i - 1];
  }
  printf("%d", f[n]);
}
