#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 100005;
pair<long long, int> f[N];
pair<long long, int> bsd(pair<long long, int> a, pair<long long, int> b) {
  if (a.first > b.first || a.first == b.first && a.second < b.second)
    return a;
  else
    return b;
}
long long l[N], r[N];
int get(long long n, long long target, long long j) {
  while (j <= n && target > r[j]) ++j;
  return j;
}
long long maxi[N];
int main() {
  int i, j = 1, n;
  long long L, p, t;
  scanf("%I64d%d%I64d%I64d", &L, &n, &p, &t);
  for (i = 1; i <= n; i++) scanf("%I64d%I64d", &l[i], &r[i]);
  for (i = 1; i <= n; i++) {
    maxi[i] = max(maxi[i], maxi[i - 1]);
    f[i] = bsd(f[i], make_pair(maxi[i] + (r[i] - l[i]) / p,
                               l[i] + ((r[i] - l[i]) / p) * p));
    long long t0 = f[i].second + t;
    j = get(n, t0, j);
    if (j > n) continue;
    if (l[j] >= t0) {
      maxi[j] = max(maxi[j], f[i].first);
      continue;
    }
    f[j] = bsd(f[j], make_pair(f[i].first + (r[j] - t0) / p,
                               t0 + ((r[j] - t0) / p) * p));
    maxi[j + 1] = max(maxi[j + 1], f[i].first);
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) ans = max(ans, f[i].first);
  printf("%I64d\n", ans);
  return 0;
}
