#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int L, n, p, T;
int f[N], g[N];
int main() {
  scanf("%d%d%d%d", &L, &n, &p, &T);
  g[0] = -T;
  for (int i = 1, l, r, j = 1; i <= n; i++) {
    scanf("%d%d", &l, &r);
    f[i] = f[i - 1];
    g[i] = g[i - 1];
    for (j--; j < i && g[j] + T <= r; j++) {
      int x = max(l, g[j] + T), y = f[j] + (r - x) / p, z = r - (r - x) % p;
      if (y > f[i] || (y == f[i] && z < g[i])) f[i] = y, g[i] = z;
    }
  }
  printf("%d\n", f[n]);
}
