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