#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int f[maxn], g[maxn];
int main() {
  int l, n, p, t;
  scanf("%d%d%d%d", &l, &n, &p, &t);
  int head = 1, tail = 1;
  f[head] = 0, g[head] = -t;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x, y, ans1, ans2;
    scanf("%d%d", &x, &y);
    ans1 = ans2 = 0;
    if (head > 1) head--;
    while (head <= tail && g[head] + t <= y) {
      int nx = max(x, g[head] + t);
      int ny = y;
      if (f[head] + (ny - nx) / p > ans1) {
        ans1 = f[head] + (ny - nx) / p;
        ans2 = nx + (ny - nx) / p * p;
      } else if (f[head] + (ny - nx) / p == ans1) {
        ans2 = min(ans2, nx + (ny - nx) / p * p);
      }
      ++head;
    }
    if (ans1 > ans) {
      ans = ans1;
      tail++;
      f[tail] = ans1;
      g[tail] = ans2;
    }
  }
  printf("%d\n", ans);
  return 0;
}
