NOI Contest Archive

Archive / 2022 / Final Round — Day 1

Two Spindles

Medium · National Olympiad in Informatics Sri Lanka 2022 - Day 1

Nimal and his group of friends are going to create a Vesak decoration. To create the Vesak decoration, they bought a set of N disks of different radii and two spindles. The decoration will be created by mounting disks on the spindles. But unfortunately, the maximum difference between the radius of any two disks in a spindle cannot exceed K. Nimal wants your support to know the maximum beauty value of the decoration so that he can show the decoration confidently to the public. The beauty value increases with the number of disks used therefore Nimal wants to know how many disks can be mounted to the two spindles. (Any number of disks can be mounted to a spindle while satisfying the conditions for the radii).

You have to help Nimal calculate the maximum number of disks that can be mounted.

image

Input Format

First Line: N K

Next N lines: radius of the ith disk

Output Format

A single integer denoting the maximum number of disks that can be mounted.

Constraints

Limits

Sample Input 0

7 3
10
5
1
12
9
5
14

Sample Output 0

5