#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int l[N], r[N];
int L, n, p, t;
pair<int, int> f[N];
int main() {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  for (int i = 1; i <= n; i++) scanf("%d%d", l + i, r + i);
  f[n + 1] = {0, 2e9 + 10};
  for (int i = n, j = n; i >= 1; i--) {
    int cnt = (r[i] - l[i]) / p;
    int t1 = l[i] + cnt * p + t;
    while (l[j] >= t1) j--;
    f[i] = make_pair(cnt + f[j + 1].first,
                     min(f[j + 1].second - t, r[i]) - cnt * p);
    if (j > i && t1 < r[j]) {
      cnt = (min(f[j].second - t, r[i]) - l[i]) / p;
      if (cnt > 0)
        f[i] = max(f[i], make_pair(cnt + f[j].first,
                                   min(f[j].second - t, r[i]) - cnt * p));
    }
    f[i] = max(f[i], f[i + 1]);
  }
  printf("%d\n", f[1].first);
  return 0;
}
