#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N];
int seg[N][2];
struct node {
  int dis, ans;
  node(int _ans = 0, int _dis = 0) { ans = _ans, dis = _dis; }
};
node q[N * 5];
int L, n, p, t;
int top, tail;
void solve(int id, node &tmp, node q) {
  int cot = seg[id][1] - max(seg[id][0], q.dis + t);
  cot /= p;
  q.ans += cot;
  q.dis = max(seg[id][0], q.dis + t) + cot * p;
  if (q.ans > tmp.ans || (q.ans == tmp.ans && q.dis < tmp.dis)) {
    tmp = q;
  }
}
int main(int argc, const char *argv[]) {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", seg[i], seg[i] + 1);
  }
  int ans = 0;
  top = tail = 0;
  q[tail++] = node(0, -t);
  for (int i = 1; i <= n; ++i) {
    node tmp(0, seg[i][1]);
    if (top) top--;
    while (top < tail) {
      if (q[top].dis + p + t > seg[i][1]) {
        break;
      }
      solve(i, tmp, q[top++]);
    }
    if (ans < tmp.ans) {
      ans = tmp.ans;
      q[tail++] = tmp;
    }
  }
  printf("%d\n", ans);
  return 0;
}

### Prompt

Your task is to create a CPP solution to the following problem:

Once Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x = 0 to x = L with a constant speed and does not change direction of movement.

There are n street lights at the road, each of which lights some continuous segment of the road. All of the n lightened segments do not share common points.

Danil loves to sing, thus he wants to sing his favourite song over and over again during his walk. As soon as non-lightened segments of the road scare him, he sings only when he goes through the lightened segments.

Danil passes distance p while performing his favourite song once. Danil can't start another performance if the segment passed while performing is not fully lightened. Moreover, if Danil has taken a pause between two performances, he is not performing while not having passed a segment of length at least t. Formally,

  1. Danil can start single performance at a point x only if every point of segment [x, x + p] is lightened; 
  2. If Danil has finished performing at a point x + p, then the next performance can be started only at a point y such that y = x + p or y ≥ x + p + t satisfying the statement under the point 1. 

<image> Blue half-circles denote performances. Please note that just after Danil has taken a pause in performing, he has not sang for a path of length of at least t.

Determine how many times Danil can perform his favourite song during his walk from x = 0 to x = L.

Please note that Danil does not break a single performance, thus, started singing another time, he finishes singing when having a segment of length of p passed from the performance start point.

Input

The first line of the input contains four integers L, n, p and t (1 ≤ L ≤ 109, 0 ≤ n ≤ 100 000, 1 ≤ p ≤ 109, 1 ≤ t ≤ 109) — the length of the Danil's path, the number of street lights at the road, the distance Danil passes while doing single performance and the minimum distance of pause respectively.

The next n lines describe segments lightened by street lights. i-th of them contains two integers li, ri (0 ≤ li < ri ≤ L) — the endpoints of the segment lightened by i-th street light. It is guaranteed that no two segments are intersecting, nesting, or touching each other. The segments are given in the order from left to right.

Output

Print the only integer — the maximum number of performances of Danil's favourite song on the path from x = 0 to x = L.

Examples

Input

17 2 2 6
0 9
13 17


Output

5


Input

12 2 2 2
0 5
6 11


Output

4


Input

12 2 2 4
0 5
6 11


Output

3

Note

The first sample case is just about corresponding to the picture from the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N];
int seg[N][2];
struct node {
  int dis, ans;
  node(int _ans = 0, int _dis = 0) { ans = _ans, dis = _dis; }
};
node q[N * 5];
int L, n, p, t;
int top, tail;
void solve(int id, node &tmp, node q) {
  int cot = seg[id][1] - max(seg[id][0], q.dis + t);
  cot /= p;
  q.ans += cot;
  q.dis = max(seg[id][0], q.dis + t) + cot * p;
  if (q.ans > tmp.ans || (q.ans == tmp.ans && q.dis < tmp.dis)) {
    tmp = q;
  }
}
int main(int argc, const char *argv[]) {
  scanf("%d%d%d%d", &L, &n, &p, &t);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", seg[i], seg[i] + 1);
  }
  int ans = 0;
  top = tail = 0;
  q[tail++] = node(0, -t);
  for (int i = 1; i <= n; ++i) {
    node tmp(0, seg[i][1]);
    if (top) top--;
    while (top < tail) {
      if (q[top].dis + p + t > seg[i][1]) {
        break;
      }
      solve(i, tmp, q[top++]);
    }
    if (ans < tmp.ans) {
      ans = tmp.ans;
      q[tail++] = tmp;
    }
  }
  printf("%d\n", ans);
  return 0;
}

```