#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long l[maxn], r[maxn];
pair<long long, long long> f0[maxn], f[maxn];
pair<long long, long long> bsd(pair<long long, long long> a,
                               pair<long long, long long> b) {
  if (a.first > b.first || (a.first == b.first && a.second < b.second))
    return a;
  return b;
}
int query(long long x, int n) { return lower_bound(r + 1, r + 1 + n, x) - r; }
void solve() {
  int i, j, n;
  long long L, p, t;
  cin >> L >> n >> p >> t;
  for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
  l[n + 1] = L + 1;
  r[n + 1] = L + 2;
  for (int i = 1; i <= n; i++) {
    f0[i] = bsd(f0[i], f0[i - 1]);
    f[i] = bsd(f[i],
               {f0[i].first + (r[i] - l[i]) / p, l[i] + (r[i] - l[i]) / p * p});
    long long t0 = f[i].second + t;
    j = query(t0, n + 1);
    if (j > n) continue;
    if (l[j] >= t0) {
      f0[j] = bsd(f0[j], {f[i].first, t0});
      continue;
    }
    f[j] = bsd(f[j], {f[i].first + (r[j] - t0) / p, t0 + (r[j] - t0) / p * p});
    f0[j + 1] = bsd(f0[j + 1], {f[i].first, t0});
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, f[i].first);
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
