#include <bits/stdc++.h>
using namespace std;
int l, n, p, t, head, tail;
int f[100005], g[100005], q[100005];
struct node {
  int x;
  int y;
} lam[100005];
int main() {
  scanf("%d%d%d%d", &l, &n, &p, &t);
  for (int i = 1; i <= n; i++) scanf("%d%d", &lam[i].x, &lam[i].y);
  head = 1, tail = 0;
  g[0] = -t;
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1];
    g[i] = g[i - 1];
    head--;
    while (head <= tail && g[q[head]] + t <= lam[i].y) {
      int x = max(g[q[head]] + t, lam[i].x);
      int y = f[q[head]] + (lam[i].y - x) / p;
      int z = lam[i].y - (lam[i].y - x) % p;
      if (y > f[i] || (y == f[i] && z < g[i])) {
        f[i] = y;
        g[i] = z;
      }
      head++;
    }
    q[++tail] = i;
  }
  printf("%d\n", f[n]);
  return 0;
}
