#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e5 + 10;
int l[SIZE], r[SIZE];
int ma[SIZE];
pair<int, int> dp[SIZE];
int p, t;
int cal(int idx, int st) {
  int ll = -1, rr = idx - 1;
  while (ll < rr) {
    int mm = (ll + rr + 1) / 2;
    if (l[mm] + p <= st - t)
      ll = mm;
    else
      rr = mm - 1;
  }
  if (ll < 0) return 0;
  int ret = 0;
  if (st - t >= l[ll] && st - t <= r[ll]) {
    if (st - t < dp[ll].first)
      ret = dp[ll].second - 1;
    else
      ret = dp[ll].second + (st - t - dp[ll].first) / p;
    if (ll) ret = max(ret, ma[ll - 1]);
  }
  if (st - t >= r[ll]) ret = max(ret, ma[ll]);
  return ret;
}
int main() {
  int L, n;
  scanf("%d%d", &L, &n);
  if (!n) return 0 * puts("0");
  scanf("%d%d", &(p), &(t));
  for (int i = 0; i < (n); ++i) scanf("%d%d", &(l[i]), &(r[i]));
  dp[0] = make_pair(l[0], 0);
  ma[0] = (r[0] - l[0]) / p;
  for (int i = (1); i < (n); ++i) {
    int base = cal(i, l[i]);
    int ll = 1, rr = min(r[i] - l[i] + 1, p);
    while (ll < rr) {
      int mm = (ll + rr) / 2;
      if (cal(i, l[i] + mm) == base)
        ll = mm + 1;
      else
        rr = mm;
    }
    if (ll == min(p, r[i] - l[i] + 1)) ll = 0;
    dp[i] = make_pair(l[i] + ll, cal(i, l[i] + ll));
    ma[i] = max(ma[i - 1], dp[i].second + (r[i] - dp[i].first) / p);
  }
  printf("%d\n", ma[n - 1]);
  return 0;
}
