#include <bits/stdc++.h>
using namespace std;
int L, n, p, t;
int l, r;
int f[100010], g[100010];
int main() {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  g[0] = -t;
  for (int i = 1, j = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    j--;
    for (; j < i && g[j] + t < r; j++) {
      l = max(l, g[j] + t);
      int tmp = (r - l) / p + f[j];
      if (tmp > f[i] || (tmp == f[i] && l + (r - l) / p * p < g[i])) {
        f[i] = tmp;
        g[i] = l + (r - 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\n", f[n]);
  return 0;
}
