#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int inf = 0x3f3f3f3f;
int l, p, n, t;
int f[maxn];
int g[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (cin >> l >> n >> p >> t) {
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    int x, y;
    g[0] = -t;
    int j = 1;
    for (int i = 1; i <= n; i++) {
      cin >> x >> y;
      g[i] = g[i - 1];
      f[i] = f[i - 1];
      for (j--; j < i && g[j] + t <= y; j++) {
        int a = max(x, g[j] + t);
        int b = f[j] + (y - a) / p;
        int c = y - (y - a) % p;
        if (f[i] < b || (f[i] == b && g[i] > c)) f[i] = b, g[i] = c;
      }
    }
    cout << f[n] << endl;
  }
  return 0;
}
