#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x3f3f3f3f;
int n, p, m, t;
int l[100001], r[100001];
int f[100001], g[100001];
inline char nc() {
  char buf[100000], *p1 = buf, *p2 = buf;
  if (p1 == p2) {
    p2 = (p1 = buf) + fread(buf, 1, 100000, stdin);
    if (p1 == p2) return EOF;
  }
  return *p1++;
}
inline void read(int &x) {
  char c = getchar();
  int b = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') b = -1;
  for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar())
    ;
  x = x * b;
}
inline void read(long long &x) {
  char c = getchar();
  int b = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') b = -1;
  for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar())
    ;
  x = x * b;
}
int main(int argc, char *argv[]) {
  read(m);
  read(n);
  read(p);
  read(t);
  for (int i = (1); i <= (n); i++) read(l[i]), read(r[i]);
  g[0] = -t;
  int pos = 1;
  for (int i = (1); i <= (n); i++) {
    pos--;
    while (g[pos] + t <= r[i] && pos <= i - 1) {
      int cnt = (r[i] - ((g[pos] + t) < (l[i]) ? (l[i]) : (g[pos] + t))) / p;
      int f1 = f[pos] + cnt,
          g1 = ((g[pos] + t) < (l[i]) ? (l[i]) : (g[pos] + t)) + cnt * p;
      if (f[i] < f1 || (f[i] == f1 && g[i] > g1)) f[i] = f1, g[i] = g1;
      pos++;
    }
    if (f[i - 1] > f[i] || (g[i - 1] < g[i] && f[i - 1] == f[i]))
      f[i] = f[i - 1], g[i] = g[i - 1];
  }
  printf("%d\n", f[n]);
  return 0;
}
