#include <bits/stdc++.h>
using namespace std;
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(long long &x, long long y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(long long &x, long long y) { return (y > x) ? x = y, 1 : 0; }
const int N = 100000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const long double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  int L, n, p, t;
  cin >> L >> n >> p >> t;
  int ans = 0;
  int pos = 0;
  vector<pair<int, int> > best;
  int best_past = 0;
  for (int i = (0); i < (n); i++) {
    int l, r;
    cin >> l >> r;
    if (l > L) {
      break;
    }
    r = min(r, L);
    while (pos < (int)best.size() && best[pos].first < l) {
      setmax(best_past, best[pos].second);
      pos++;
    }
    int cnt = 0, last = r;
    int cnt1 = best_past + (r - l) / p, last1 = l + (r - l) / p * p;
    if (cnt1 > cnt || cnt1 == cnt && last1 < last) {
      cnt = cnt1;
      last = last1;
    }
    while (pos < (int)best.size() && best[pos].first <= r) {
      setmax(best_past, best[pos].second);
      cnt1 = best[pos].second + (r - best[pos].first) / p;
      last1 = best[pos].first + (r - best[pos].first) / p * p;
      if (cnt1 > cnt || cnt1 == cnt && last1 < last) {
        cnt = cnt1;
        last = last1;
      }
      pos++;
    }
    setmax(ans, cnt);
    best.push_back({last + t, cnt});
  }
  cout << ans << "\n";
  return 0;
}
