Admission to the University#288

Admission to the University

0.5 seconds
64 megabytes
Easy (≈1000)

There are individuals who have passed the technical phase of the extttUniversity of Seattle (Washington). However, this does not yet mean that they will definitely study there. The university selects its students based on their social skills in the next phase. The social skill of each candidate who passed the technical phase has already been evaluated by the university. This is equal to s_i for the -th candidate.

The university conducts the selection process based on a parameter called the selection range. Let's denote this parameter by . The university wants to select candidates such that the social skill difference between the most social and the least social student among them does not exceed . This is the most optimal option for their mutual interaction in student life. Within this condition, the university wants to admit as many students as possible. Determine the maximum number of students the university can admit.

Input data

The first line contains two integers (1 \leq n \leq 10^{5}) and (0 \leq d \leq 10^{9}) – the number of candidates and the selection range, respectively. The second line contains integers s_1,s_2,....,s_n (-10^{9} \leq s_i \leq 10^{9}) – the social skills of the candidates.

Output data

Output a single line with the maximum number of students the university can admit.

Subtasks

This problem consists of 4 subtasks as follows:

Explanation of the sample

The university can admit a maximum of students, these could be the candidates numbered {1,3,4} or {2,3,5}. The social skill difference between the most social and the least social candidates in both sets is not greater than d=3.

Examples

Example 1

Loading
Loading