#include <bits/stdc++.h>
int cur[100010], h[100010], L, n, p, t;
int main() {
  scanf("%d%d%d%d\n", &L, &n, &p, &t);
  h[0] = -t;
  for (int i = 1, j = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    h[i] = h[i - 1];
    cur[i] = cur[i - 1];
    for (j -= 1; j < i && h[j] + t <= r; j++) {
      int x = std::max(h[j] + t, l), y = cur[j] + (r - x) / p,
          z = r - (r - x) % p;
      if (y > cur[i] || (y == cur[i] && z < h[i])) cur[i] = y, h[i] = z;
    }
  }
  printf("%d", cur[n]);
}
