#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int f[100010], g[100010], q[100010];
signed main() {
  int L = read(), n = read(), p = read(), T = read();
  g[0] -= T;
  int t = 1, w = 1;
  for (int i = 1; i <= n; ++i) {
    int l = read(), r = read();
    g[i] = g[i - 1];
    f[i] = f[i - 1];
    t--;
    while (t <= w && g[t] + T <= r) {
      int x = max(g[t] + T, l), y = f[t] + (r - x) / p, z = r - (r - x) % p;
      if (y > f[i] || y == f[i] && z < g[i]) {
        f[i] = y;
        g[i] = z;
      }
      t++;
    }
    w++;
  }
  cout << f[n] << endl;
  return 0;
}
