#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int qdist[N], qans[N];
int l, n, p, t;
void update(int l, int r, int &tdist, int &tans, int d, int a) {
  int num = (r - max(l, d + t)) / p;
  a += num;
  d = max(l, d + t) + num * p;
  if (tans < a || (a == tans && d < tdist)) {
    tdist = d;
    tans = a;
  }
}
int main() {
  scanf("%d%d%d%d", &l, &n, &p, &t);
  int head, tail;
  head = tail = 0;
  qdist[tail] = -t;
  qans[tail] = 0;
  tail++;
  int l, r, tdist, tans;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &l, &r);
    tans = 0, tdist = 1e9 + 5;
    head = max(head - 1, 0);
    while (head < tail) {
      if (qdist[head] + t + p > r) break;
      update(l, r, tdist, tans, qdist[head], qans[head]);
      head++;
    }
    if (ans < tans) {
      ans = tans;
      qdist[tail] = tdist;
      qans[tail] = tans;
      tail++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
