Feeding Frenzy


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

Farmer Tom has recently acquired some sheep for his farm, and he needs to figure out how to feed them efficiently. These sheep have highly rigid schedules — they must each eat at a specific time in the day each day, or they will not eat.

Each sheep requires one bucket of food to be ready at precisely the time which they are scheduled to eat. However, after each sheep eats, a certain amount of time is required for the farm hands to clean the bucket before it can be used to feed another sheep. Tom wants to minimise the buckets he needs to purchase, but it is also vital that there is a bucket ready to feed the sheep at the exact time that they need feeding each day.

How many buckets will Tom need at minimum to feed all of the sheep at their scheduled time?

Input

The first line contains two space-separated integers n and d (1 \leq n,d \leq 10^5) — the number of sheep and the amount of time required to clean each bucket immediately after its use, respectively.

The next line contains n space-separated integers a_i (1 \leq a_i\leq 10^5), the time of day at which the ith sheep needs to be fed, given in non-decreasing order.

Output

Output the minimum number of buckets required to feed all sheep, where each sheep needs to be fed at a certain time and each bucket needs d time to pass after being used before it can be reused.

Example

Input 1
5 3
1 2 3 4 10
Output 1
3
  • The sheep at time 1 obviously requires a new bucket. The same bucket will be available again at time 4.
  • The sheep at time 2 requires a new bucket. The bucket will become available at time 5.
  • The sheep at time 3 requires a new bucket.
  • The sheep at time 4 can reuse the previous bucket from the sheep at time 1, as it has been cleaned.
  • By time 10, all buckets will have been cleaned, so we can use any of them.
Input 2
4 2
5 5 5 5
Output 2
4

Each sheep requires its own bucket since they all must be fed at the same time, so there is no way to clean them in between feeding schedules.

Input 3
6 1
1 2 2 3 4 5
Output 3
2

Since each bucket only needs 1 second to be cleaned, the only case where multiple buckets are needed is if multiple sheep need to be fed at the same time. Since 2 sheep need to be fed at time 2, 2 buckets are required.


Comments

There are no comments at the moment.