#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0;
  for (; ch > '9' || ch < '0'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x;
}
int f[100010], g[100010], L[100010], R[100010], q[100010];
int main() {
  int LL = read(), n = read(), p = read(), t = read();
  for (int i = 1; i <= n; i++) {
    L[i] = read(), R[i] = read();
    if (R[i] - L[i] < p) i--, n--;
  }
  if (R[n] > LL) R[n] = LL;
  f[0] = 0;
  g[0] = -t;
  int H = 0, T = 0, ans = 0;
  q[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (H ? --H : H; H <= T; H++) {
      int j = q[H];
      if (g[j] + t > R[i]) break;
      if (f[i] < (R[i] - max(g[j] + t, L[i])) / p + f[j]) {
        f[i] = (R[i] - max(g[j] + t, L[i])) / p + f[j];
        g[i] = R[i] - (R[i] - max(L[i], g[j] + t)) % p;
      } else {
        if (f[i] == (R[i] - max(g[j] + t, L[i])) / p + f[j])
          g[i] = min(g[i], (R[i] - (R[i] - max(L[i], g[j] + t)) % p));
      }
    }
    if (f[i] > ans) {
      q[++T] = i;
      ans = max(ans, f[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
