cswork / OAOpen practice workspace

AmazonOA #242

Group Students (AS Intern, it may apply to other interns)

Estimated EasyJudge-ready

Topics (AI-labelled)GreedyIn-place Arrays

Divide all students into classes so that any two students in the same class differ in skill by at most maxSpread; find the minimum number of classes. Groups do not need to keep original indices adjacent, and different students with the same skill must all be placed.

Input

The first line contains n maxSpread; the second line contains the skills. The original text gives n≤100000 and a skill upper bound of 10^9, but the lower bounds were damaged in typesetting and no bound was given for maxSpread; this site explicitly uses 1≤n≤100000, 1≤skill≤10^9, 0≤maxSpread≤10^9.

Output

Output a single integer, the answer.

Example 1

Input:

5 2
1 4 7 3 4

Output:

3

Example 2

Input:

3 1
1 2 3

Output:

2

Example 3

Input:

3 0
7 7 7

Output:

1

Example notes

The answers are 3, 2 and 1. Adjacent skill differences all being ≤1 does not mean 1,2,3 can share a class.

Editorial

Loading solution…