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