#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 7;
const int M = 100 + 3;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const bool multipleTest = false;
vector<pair<int, int> > ans;
int L, n, p, t;
void solve() {
  cin >> L >> n >> p >> t;
  ans.push_back(make_pair(-t, 0));
  for (int i = 0; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (v - u < p) continue;
    int lo = 0, hi = (int)(ans).size() - 1, res = -1;
    while (lo <= hi) {
      int g = (lo + hi) / 2;
      if (ans[g].first + t <= u) {
        res = g;
        lo = g + 1;
      } else
        hi = g - 1;
    }
    int cur = ans[res].second + (v - u) / p;
    int ppp = ((v - u) / p) * p + u;
    if (res + 1 == (int)(ans).size() ||
        ((1ll * ans[res + 1].first + t + p) > v)) {
      if (cur > ans.back().second) ans.push_back(make_pair(ppp, cur));
      continue;
    }
    ++res;
    int lefPoint = max(ans[res].first + t, u);
    int nxt = (v - lefPoint) / p + ans[res].second;
    if (max(nxt, cur) <= ans.back().second) continue;
    int lastPoint = lefPoint + p * (nxt - ans[res].second);
    if (nxt > cur || (nxt == cur && lastPoint < ppp)) {
      ans.push_back(make_pair(lastPoint, nxt));
    } else {
      ans.push_back(make_pair(ppp, cur));
    }
  }
  cout << ans.back().second << "\n";
}
void createTest() {
  freopen("in.txt", "w", stdout);
  cout << 5 << "\n";
  for (int t = 0; t < 5; ++t) {
    cout << 50 << "\n";
    for (int i = 1; i <= 50; ++i) {
      cout << rand() % 100000 << " ";
    }
    puts("");
    cout << 1 << "\n1 2 3\n";
  }
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
