#include <bits/stdc++.h>
using namespace std;
int now, m, n, p, t, f[100005], g[100005], ans;
void up(int k, int w, int x, int y) {
  if (w + (y - x) / p > f[k]) {
    f[k] = w + (y - x) / p;
    g[k] = x + (y - x) / p * p;
  } else if (w + (y - x) / p == f[k])
    g[k] = min(g[k], x + (y - x) / p * p);
}
int main() {
  scanf("%d%d%d%d", &m, &n, &p, &t);
  int x, y;
  g[0] = -t;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (now) now--;
    for (; now < i && g[now] + t <= y; now++)
      if (g[now] + t <= x)
        up(i, f[now], x, y);
      else
        up(i, f[now], g[now] + t, y);
    ans = max(ans, f[i]);
    if (f[i - 1] > f[i]) {
      f[i] = f[i - 1];
      g[i] = g[i - 1];
    } else if (f[i - 1] == f[i])
      g[i] = min(g[i], g[i - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
