#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
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 << 1) + (x << 3) + ch - '0', ch = getchar();
  return x * f;
}
int len, n, p, t, Max, f[100005], g[100005], l[100005], r[100005];
int main() {
  len = read();
  n = read();
  p = read();
  t = read();
  for (int i = 1; i <= n; i++) l[i] = read(), r[i] = read();
  int i, j = 1;
  g[0] = -t;
  for (i = 1; i <= n; i++) {
    for (j = j - 1; j <= i - 1; j++)
      if (g[j] + t <= r[i]) {
        int now = f[j] + (r[i] - max(l[i], g[j] + t)) / p;
        if (now > f[i])
          f[i] = now, g[i] = r[i] - (r[i] - max(l[i], g[j] + t)) % p;
        else if (now == f[i])
          g[i] = min(g[i], r[i] - (r[i] - max(l[i], g[j] + t)) % p);
      } else
        break;
    if (f[i - 1] > f[i] || f[i - 1] == f[i] && g[i - 1] < g[i])
      f[i] = f[i - 1], g[i] = g[i - 1];
  }
  printf("%d\n", f[n]);
  return 0;
}
