Cossack Vus and Segments#10486

Cossack Vus and Segments

2 seconds
256 megabytes
Easy

Cossack Vus has discovered segments on a coordinate line. Each segment is defined by two coordinates: a_i as the starting point and b_i as the ending point.

He wants to add two new segments, each of length , in such a way that these two segments do not overlap. Let represent the number of original segments that completely contain the first new segment, and represent the number of original segments that completely contain the second new segment.

Cossack Vus aims to position these two segments to maximize the sum x+y. Your task is to help him determine this maximum value.

Note that a single original segment can completely contain both new segments at the same time.

Note 1. If k_1 and k_2 (k_1 < k_2) are the starting points of the new segments, then the segments do not overlap if k_1 + m \le k_2.

Note 2. A new segment starting at is completely contained within an original segment [l, r] if l \le k and k + m \le r.

Input

The first line contains two integers and (1 \le n \le 3 \cdot 10^5, 1 \le m \le 10^8) — the number of original segments and the length of the new segments.

Each of the following lines contains two integers a_i, b_i (1 \le a_i < b_i \le 10^8) — the start and end coordinates of each original segment.

Output

Output a single integer — the maximum possible value of x+y.

Examples

Example 1

Loading
Loading

Scoring

  1. ( points): n, m, a_i, b_i \le 200;

  2. ( points): n \le 200;

  3. ( points): n \le 2000;

  4. ( points): n \le 2 \cdot 10^5, m=1;

  5. ( points): no additional constraints.