#include <bits/stdc++.h>
using namespace std;
int ans[100100], pos[100100], l[100100], r[100100];
int main() {
  int L, n, p, t;
  cin >> L >> n >> p >> t;
  for (int i = 1; i <= n; i++) scanf("%d %d", &l[i], &r[i]);
  pos[0] = -t;
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    while (pos[pre] + t <= r[i] && pre < i) {
      int st = max(l[i], pos[pre] + t);
      int tmp = ans[pre] + (r[i] - st) / p;
      if (ans[i] < tmp) {
        ans[i] = tmp;
        pos[i] = st + (r[i] - st) / p * p;
      } else if (ans[i] == tmp)
        pos[i] = min(pos[i], st + (r[i] - st) / p * p);
      pre++;
    }
    if (ans[i] < ans[i - 1]) {
      ans[i] = ans[i - 1];
      pos[i] = pos[i - 1];
    } else if (ans[i] == ans[i - 1])
      pos[i] = min(pos[i], pos[i - 1]);
    pre = max(pre - 1, 0);
  }
  cout << ans[n] << endl;
  return 0;
}
