#include <bits/stdc++.h>
using namespace std;
inline void MIN(int &a, int b) {
  if (a == -1 || a > b) a = b;
}
inline void MAX(int &a, int b) {
  if (a < b) a = b;
}
template <class T>
inline void rd(T &res) {
  res = 0;
  char c;
  int k = 1;
  while (c = getchar(), c < '0')
    if (c == '-') k = -1;
  do {
    res = (res << 1) + (res << 3) + (c ^ 48);
  } while (c = getchar(), c >= '0');
  res *= k;
}
template <class T>
inline void pt(T k) {
  if (k == 0) return;
  pt(k / 10);
  putchar((k % 10) ^ 48);
}
template <class T>
inline void sc(T k) {
  pt(k);
  if (k == 0) putchar('0');
  putchar('\n');
}
const int M = 1e5 + 5;
int dp[M], pos[M], l, r;
int L, n, p, t, ans;
inline void cal(int i, int num, int l, int r) {
  num += (r - l) / p;
  if (dp[i] < num) pos[i] = l + (r - l) / p * p;
  if (dp[i] == num) MIN(pos[i], l + (r - l) / p * p);
  MAX(dp[i], num);
}
int main() {
  int i, j = 1, k, ans = 0;
  rd(L);
  rd(n);
  rd(p);
  rd(t);
  memset(pos, -1, sizeof(pos));
  pos[0] = -t;
  for (i = 1; i <= n; i++) {
    rd(l), rd(r);
    j--;
    for (; j < i && pos[j] + t <= r; j++) cal(i, dp[j], max(pos[j] + t, l), r);
    MAX(ans, dp[i]);
    if (dp[i] < dp[i - 1]) dp[i] = dp[i - 1], pos[i] = pos[i - 1];
    if (dp[i] == dp[i - 1]) MIN(pos[i], pos[i - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
