#include <bits/stdc++.h>
using std::max;
int L, n, p, t, f[1000100], g[1000100], l, r;
int main() {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  g[0] = -t;
  for (int i = 1, now = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    f[i] = f[i - 1], g[i] = g[i - 1];
    for (--now; now < i && g[now] + t <= r; now++) {
      int x = max(g[now] + t, l);
      int F = f[now] + (r - x) / p, G = r - (r - x) % p;
      if (F > f[i] || F == f[i] && G < g[i]) f[i] = F, g[i] = G;
    }
  }
  printf("%d\n", f[n]);
}
