#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int l[N], r[N], dp[N][111], ans[N], n, p, t, L, f[N * 111];
void solve1() {
  for (int i = 1; i <= n; i++) {
    ans[i] = ans[i - 1];
    for (int j = 0; j < p; j++) {
      if (r[i] - j < l[i] + p) continue;
      int c = (r[i] - j - l[i]) / p, x = r[i] - j - c * p - t,
          u = lower_bound(r + 1, r + 1 + n, x) - r;
      dp[i][j] = ans[u - 1] + c;
      if (l[u] <= x) {
        if (c > (r[u] - x) / p)
          dp[i][j] = max(dp[i][j], dp[u][(r[u] - x) % p] + c - (r[u] - x) / p);
      }
      ans[i] = max(ans[i], dp[i][j]);
    }
  }
  cout << ans[n] << endl;
}
void solve2() {
  int ans = 0;
  f[0] = l[1];
  int cur = 1;
  for (int i = 0; cur <= n; i++) {
    if (r[cur] - f[i] >= p)
      f[i + 1] = f[i] + p, ans = i + 1;
    else {
      while (1) {
        cur++;
        if (cur > n) break;
        int low = l[cur] + p, high = r[cur] + 1;
        if (low >= high) continue;
        while (low < high) {
          int mid = low + high >> 1;
          int c = (mid - l[cur]) / p;
          if (c >= i + 1 || f[i + 1 - c] <= mid - c * p - t)
            high = mid;
          else
            low = mid + 1;
        }
        if (low <= r[cur]) {
          f[i + 1] = low;
          ans = i + 1;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> L >> n >> p >> t;
  for (int i = 1; i <= n; i++) scanf("%d%d", l + i, r + i);
  if (p <= 100)
    solve1();
  else
    solve2();
  return 0;
}
