#include <bits/stdc++.h>
using namespace std;
const long maxn = 1e5 + 1;
long L, n, p, t;
long f[maxn], g[maxn];
int main() {
  scanf("%ld%ld%ld%ld", &L, &n, &p, &t);
  f[0] = g[0] = 0;
  long now = 0;
  for (long i = 1; i <= n; i++) {
    long l, r;
    scanf("%ld%ld", &l, &r);
    f[i] = (r - l) / p, g[i] = l + p * f[i];
    if (f[i - 1] >= f[i]) f[i] = f[i - 1], g[i] = g[i - 1];
    while (now < i && g[now] + t <= r) {
      long m = (r - max(g[now] + t, l)) / p;
      if (f[now] + m > f[i]) {
        f[i] = f[now] + m;
        g[i] = max(g[now] + t, l) + m * p;
      } else if (f[now] + m == f[i])
        g[i] = min(g[i], max(g[now] + t, l) + m * p);
      now++;
    }
    now = max((long)0, --now);
  }
  printf("%ld\n", f[n]);
  return 0;
}
