#include <bits/stdc++.h>
int L, n, p, t, f[100010], g[100010], l[100010], r[100010], Ans = 0, q[100010],
                                                            tl, tr, tA, tB;
bool Q;
int main() {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  for (int i = 1; i <= n; i++) scanf("%d%d", &l[i], &r[i]);
  f[0] = 0;
  g[0] = -t;
  q[tl = tr = 0] = 0;
  for (int i = 1; i <= n; i++) {
    tA = tB = 0;
    Q = false;
    while (tl <= tr && g[q[tl]] + t <= r[i] &&
           f[q[tl]] + (r[i] -
                       ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) /
                          p >
               tA) {
      tA = f[q[tl]] +
           (r[i] - ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) / p;
      tl++;
      Q = true;
    }
    if (Q)
      tl--;
    else
      tA = f[q[tl]] +
           (r[i] - ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) / p;
    tB = ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t)) +
         (r[i] - ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) / p * p;
    Q = false;
    while (tl <= tr && g[q[tl]] + t <= r[i] &&
           f[q[tl]] + (r[i] -
                       ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) /
                          p ==
               tA) {
      tB =
          ((tB) < (((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t)) +
                   (r[i] -
                    ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) /
                       p * p)
               ? (tB)
               : (((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t)) +
                  (r[i] - ((l[i]) > (g[q[tl]] + t) ? (l[i]) : (g[q[tl]] + t))) /
                      p * p));
      tl++;
      Q = true;
    }
    if (Q) tl--;
    f[i] = tA;
    g[i] = tB;
    if (f[i] > Ans) {
      Ans = f[i];
      q[++tr] = i;
    }
  }
  printf("%d\n", Ans);
  return 0;
}
