#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int n, p, t, l, r;
int f[maxn], g[maxn];
int head, tail, ans;
int main() {
  head = tail = 1;
  g[1] = -inf;
  scanf("%d%d%d%d", &n, &n, &p, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    int nxtans = 0, nxtg = 0;
    if (head > 1) head--;
    while (head <= tail && g[head] + p + t <= r) {
      int nowf = f[head] + (r - max(l, g[head] + t)) / p;
      int nowg = r - (r - max(l, g[head] + t)) % p;
      if (nowf > nxtans || (nowf == nxtans && nowg < nxtg)) {
        nxtans = nowf, nxtg = nowg;
      }
      head++;
    }
    if (ans < nxtans) {
      ans = nxtans;
      tail++;
      f[tail] = nxtans;
      g[tail] = nxtg;
    }
  }
  printf("%d\n", ans);
  return 0;
}
