#include <bits/stdc++.h>
using namespace std;
int n, p, t, ans, f[100010], g[100010];
struct node {
  int x, y;
} A[100010];
inline void div(int a, int b, int &c, int &r) {
  c = a / b;
  r = a % b;
}
int main() {
  scanf("%*d%d%d%d", &n, &p, &t);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &A[i].x, &A[i].y);
  g[0] = -t;
  for (int i = 1, k1 = 0, k2 = 0, mx = 0; i <= n; ++i) {
    int h, v;
    div(A[i].y - A[i].x, p, v, h);
    g[i] = A[i].y - h;
    while (g[k1] <= A[i].x - t) {
      mx = max(mx, f[k1]);
      ++k1;
    }
    f[i] = mx + v;
    k2 = k1;
    while (k2 < i && g[k2] <= A[i].y - t) {
      int hh, vv;
      div(A[i].y - g[k2] - t, p, vv, hh);
      if (f[k2] + vv > f[i] || (f[k2] + vv == f[i] && A[i].y - hh < g[i])) {
        f[i] = f[k2] + vv;
        g[i] = A[i].y - hh;
      }
      ++k2;
    }
    ans = max(ans, f[i]);
  }
  printf("%d\n", ans);
  return 0;
}
