#include <bits/stdc++.h>
using namespace std;
pair<int, int> v[100010];
int main() {
  int l, n, p, t;
  scanf("%d %d %d %d", &l, &n, &p, &t);
  v[1] = {0, -t};
  int ma = 0, st = 1, dr = 1;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    int lma = 0, ldist = 2000000000;
    for (; st <= dr; ++st) {
      if (v[st].second + t + p > y) break;
      int nr = y - max(x, v[st].second + t);
      nr /= p;
      int dist = max(x, v[st].second + t) + nr * p;
      nr += v[st].first;
      if (nr > lma || (nr == lma && ldist > dist)) lma = nr, ldist = dist;
    }
    if (st > 1) --st;
    if (ma < lma) {
      v[++dr] = {lma, ldist};
      ma = lma;
    }
  }
  printf("%d\n", ma);
  return 0;
}
