#include <bits/stdc++.h>
using namespace std;
const long long N = 200010;
long long l[N], r[N], f[N], g[N], L, n, p, t, q[N], head, tail, ans;
void up(long long i, long long a, long long b) {
  if (a > f[i]) {
    f[i] = a;
    g[i] = b;
  } else if (a == f[i]) {
    g[i] = min(g[i], b);
  }
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &L, &n, &p, &t);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &l[i], &r[i]);
  g[0] = -t;
  for (int i = 1; i <= n; i++) {
    up(i, f[i - 1], g[i - 1]);
    for (int j = head; j < i && g[j] + t <= r[i]; j++) {
      long long left = max(g[j] + t, l[i]);
      long long cnt = (r[i] - left) / p;
      long long pos = left + cnt * p;
      up(i, f[j] + cnt, pos);
    }
    while (head < i - 1 && g[head] + t < l[i]) head++;
    if (head) head--;
    ans = max(ans, f[i]);
  }
  printf("%I64d", ans);
  return 0;
}
