#include <bits/stdc++.h>
using namespace std;
int f[100010], g[100010];
int _Max(int x, int y) { return x > y ? x : y; }
void upd(int x, int ans, int k) {
  if (f[x] < ans)
    f[x] = ans, g[x] = k;
  else if (f[x] == ans && k < g[x])
    g[x] = k;
}
int main() {
  int n, L, p, t, i, j, l = 1, r = 0, x, y, s = 0, ans = 0;
  scanf("%d%d%d%d", &L, &n, &p, &t);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    while (r < i - 1 && g[r + 1] + t <= y) r++;
    while (l < i && g[l] + t <= x) s = _Max(s, f[l++]);
    f[i] = -1;
    upd(i, s + (y - x) / p, x + (y - x) / p * p);
    for (j = l; j <= r; j++)
      upd(i, f[j] + (y - g[j] - t) / p, g[j] + t + (y - g[j] - t) / p * p);
    ans = _Max(ans, f[i]);
  }
  printf("%d\n", ans);
  return 0;
}
