This page is still under construction.

Parts of this page are still being built. What you see may change.

Wrestling Competition

Time limit1sMemory limit512 MB

Summary
Given strengths and a threshold K, count players who could be the last survivor when random pairings are played and a match is decided by strength unless the gap is at most K.
Level

Medium6 of 10

Topics
Sorting, Greedy, Math, Implementation
Solved
No attempts yet

Problem

A wrestling competition will be held tomorrow. A total of nn players take part in it. The ii-th player's strength is aia_i.

If the ii-th player and the jj-th player have a match, the result depends solely on ∣ai−aj∣|a_i - a_j|. If ∣ai−aj∣>K|a_i - a_j| > K, the player with the higher strength wins. Otherwise, each player has a chance to win.

The competition rules are a little strange. For each match, the referee picks two players uniformly at random from all remaining players and holds a match between them. The loser is eliminated. After n−1n - 1 matches, the last remaining player is the winner.

Given nn, KK, and the array aa, find how many players have a chance to win the competition.

Input

The first line contains two integers nn and KK (1≤n≤1051 \leq n \leq 10^5, 0≤K<1090 \leq K < 10^9).

The second line contains nn integers aia_i (1≤ai≤1091 \leq a_i \leq 10^9).

Output

Print a single line with a single integer: the number of players which have a chance to win the competition.

Examples2

  1. Example 1

    Input
    5 3
    1 5 9 6 3
    
    Expected output
    5
    
  2. Example 2

    Input
    5 2
    1 5 9 6 3
    
    Expected output
    1