#include <bits/stdc++.h>
using namespace std;
int f[100005], g[100005];
int main() {
  int n, p, L, t;
  int nowl, nowr, top = 0, newf, newg;
  scanf("%d%d%d%d", &L, &n, &p, &t);
  g[0] = -t;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &nowl, &nowr);
    f[i] = f[i - 1];
    g[i] = g[i - 1];
    while (1) {
      newf = (nowr - max(nowl, g[top] + t)) / p + f[top];
      newg = ((nowr - max(nowl, g[top] + t)) / p) * p + max(nowl, g[top] + t);
      if (newf == f[i] && newg < g[i]) g[i] = newg;
      if (newf > f[i]) {
        f[i] = newf;
        g[i] = newg;
      }
      if (top + 1 < i && g[top + 1] + t <= nowr)
        top++;
      else
        break;
    }
  }
  printf("%d\n", f[n]);
  return 0;
}
