#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 7;
long long arr[max_n];
pair<int, int> dp[max_n];
int L, n, p, t;
pair<int, int> get_best(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first || (a.first == b.first && a.second < b.second))
    return a;
  else
    return b;
}
int main() {
  cin >> L >> n >> p >> t;
  int pos = 1;
  dp[0].first = 0;
  dp[0].second = -t;
  for (int i = int(1); i <= int(n); i++) {
    pos--;
    int l, r;
    cin >> l >> r;
    while (pos < i && dp[pos].second + t < r) {
      int st = max(l, dp[pos].second + t);
      int songs = (r - st) / p;
      int en = songs * p + st;
      dp[i] = get_best(dp[i], make_pair(dp[pos].first + songs, en));
      pos++;
    }
    dp[i] = get_best(dp[i], dp[i - 1]);
  }
  cout << dp[n].first;
  return 0;
}
