You have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them.

You know that you have $n$ bacteria in the Petri dish and size of the $i$-th bacteria is $a_i$. Also you know intergalactic positive integer constant $K$.

The $i$-th bacteria can swallow the $j$-th bacteria if and only if $a_i > a_j$ and $a_i \le a_j + K$. The $j$-th bacteria disappear, but the $i$-th bacteria doesn't change its size. The bacteria can perform multiple swallows. On each swallow operation any bacteria $i$ can swallow any bacteria $j$ if $a_i > a_j$ and $a_i \le a_j + K$. The swallow operations go one after another.

For example, the sequence of bacteria sizes $a=[101, 53, 42, 102, 101, 55, 54]$ and $K=1$. The one of possible sequences of swallows is: $[101, 53, 42, 102, \underline{101}, 55, 54]$ $\to$ $[101, \underline{53}, 42, 102, 55, 54]$ $\to$ $[\underline{101}, 42, 102, 55, 54]$ $\to$ $[42, 102, 55, \underline{54}]$ $\to$ $[42, 102, 55]$. In total there are $3$ bacteria remained in the Petri dish.

Since you don't have a microscope, you can only guess, what the minimal possible number of bacteria can remain in your Petri dish when you finally will find any microscope.


-----Input-----

The first line contains two space separated positive integers $n$ and $K$ ($1 \le n \le 2 \cdot 10^5$, $1 \le K \le 10^6$) — number of bacteria and intergalactic constant $K$.

The second line contains $n$ space separated integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^6$) — sizes of bacteria you have.


-----Output-----

Print the only integer — minimal possible number of bacteria can remain.


-----Examples-----
Input
7 1
101 53 42 102 101 55 54

Output
3

Input
6 5
20 15 10 15 20 25

Output
1

Input
7 1000000
1 1 1 1 1 1 1

Output
7



-----Note-----

The first example is clarified in the problem statement.

In the second example an optimal possible sequence of swallows is: $[20, 15, 10, 15, \underline{20}, 25]$ $\to$ $[20, 15, 10, \underline{15}, 25]$ $\to$ $[20, 15, \underline{10}, 25]$ $\to$ $[20, \underline{15}, 25]$ $\to$ $[\underline{20}, 25]$ $\to$ $[25]$.

In the third example no bacteria can swallow any other bacteria.

Difficulty: EASY
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms
Expected Time Complexity: O(NLOG(N))

Starter code:

Solutions:
[n, K] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
ais.sort()
res = 0
cnt = 1
for i in range(n - 1):
	if ais[i + 1] == ais[i]:
		cnt += 1
	else:
		if ais[i + 1] > ais[i] + K:
			res += cnt
		cnt = 1
res += cnt
print(res)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
(n, k) = mi()
a = li()
a.sort()
ans = 0
i = 0
while i < len(a):
	j = i + 1
	c = 1
	while j < len(a) and a[j] <= a[j - 1] + k:
		if a[j] == a[j - 1]:
			c += 1
		else:
			c = 1
		j += 1
	ans += c
	i = j
print(ans)


(n, K) = map(int, input().split())
A = sorted(map(int, input().split()))
ans = []
for a in A:
	while len(ans) and ans[-1] < a <= ans[-1] + K:
		ans.pop()
	ans += [a]
print(len(ans))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
arr.append(2000000000)
n += 1
j = 0
k2 = 0
for i in range(n - 1):
	while j < n and arr[j] == arr[i]:
		j += 1
	if arr[j] - arr[i] > k:
		k2 += 1
print(k2)


(n, k) = map(int, input().split())
arr = sorted((int(x) for x in input().split()))
j = 0
for x in arr:
	while arr[j] < x:
		if x <= arr[j] + k:
			n -= 1
		j += 1
print(n)


s = input()
(n, K) = list(map(int, s.split()))
s = input()
a = list(map(int, s.split()))
a = sorted(a)
c = 0
l = 0
r = 1
while r < len(a):
	if a[r] == a[l]:
		r += 1
	else:
		if a[l] + K >= a[r]:
			c += r - l
		l = r
		r += 1
print(len(a) - c)


import sys
from array import array
from bisect import bisect_right
(n, k) = map(int, input().split())
a = sorted(map(int, input().split())) + [10 ** 9]
ans = n
for x in a[:-1]:
	if a[bisect_right(a, x)] <= x + k:
		ans -= 1
print(ans)


def main():
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = set()
	a = sorted(set(A))
	a.append(10 ** 7 - 1)
	i = 0
	while i < len(a) - 1:
		if a[i] < a[i + 1] and a[i] + k >= a[i + 1]:
			B.add(a[i])
		i = i + 1
	res = [x for x in A if x not in B]
	print(len(res))
main()


from math import ceil, log
t = 1
for test in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	if n == 1:
		print(1)
		continue
	tmp = 0
	store = 0
	while i < n - 1:
		if a[i + 1] > a[i]:
			if -a[i] + a[i + 1] <= k:
				tmp += 1
				tmp += store
			store = 0
		else:
			store += 1
		i += 1
	print(n - tmp)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
arr1 = []
for i in d.keys():
	arr1.append(i)
arr1.sort()
ans = []
for i in range(1, len(arr1)):
	if arr1[i] > arr1[i - 1] and arr1[i] - arr1[i - 1] <= k:
		ans.append(d[arr1[i - 1]])
print(n - sum(ans))


import math
getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
(n, k) = getInputIntList()
arr = list(getInputIntList())
bin_arr = [True] * n
arr.sort(reverse=True)
myset = set([])
i = len(arr) - 1
while i > 0:
	if arr[i - 1] > arr[i] and arr[i - 1] <= arr[i] + k:
		bin_arr[i] = False
		myset.add(arr[i])
	i -= 1
i = len(arr) - 1
while i > 0:
	if arr[i] in myset:
		bin_arr[i] = False
		i -= 1
		continue
	if arr[i - 1] > arr[i] and arr[i - 1] <= arr[i] + k:
		bin_arr[i] = False
	i -= 1
print(bin_arr.count(True))


(n, k) = [int(x) for x in input().split()]
inp = [int(x) for x in input().split()]
ne = sorted(inp)
li = []
count = 0
for i in range(len(ne) - 1):
	if ne[i] != ne[i + 1]:
		if ne[i + 1] - ne[i] <= k:
			for i in range(count + 1):
				li.append(1)
		count = 0
	else:
		count += 1
print(n - len(li))


rd = lambda : map(int, input().split())
(n, k) = rd()
a = sorted(rd())
(r, t) = (0, 1)
l = -1e+20
for i in range(n):
	if a[i] > l + k:
		r += t
		t = 1
	elif a[i] == l:
		t += 1
	else:
		t = 1
	l = a[i]
print(r + t - 1)


from array import array
from sys import stdin
import bisect
from bisect import *
import itertools
from itertools import *

def scan_gen():
	for line in stdin:
		yield from iter(line.split())
scan = scan_gen()

def nint():
	return int(next(scan))

def nintk(k):
	return tuple((nint() for _ in range(k)))

def nfloat():
	return float(next(scan))

def intar_init(size):
	return array('i', [0]) * size

def intar(size=None):
	if size == None:
		size = nint()
	arr = intar_init(size)
	for x in range(size):
		arr[x] = nint()
	return arr

def solve():
	(n, k) = nintk(2)
	A = sorted(intar(n))
	res = 0
	for x in A:
		p = bisect_left(A, x + 1)
		if p < n and A[p] <= x + k:
			res += 1
	print(n - res)
solve()


from collections import defaultdict
(n, k) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))

def bact(a, n, k):
	b = sorted(a)
	d = defaultdict(int)
	count = 0
	for i in range(n - 1):
		if b[i + 1] > b[i] and b[i + 1] - b[i] <= k:
			d[b[i]] = 1
	for i in range(n):
		if d[b[i]] == 1:
			count += 1
	return n - count
print(bact(a, n, k))


(n, k) = map(int, input().strip().split(' '))
brr = list(map(int, input().strip().split(' ')))
arr = list(set(brr))
arr.sort(reverse=True)
n = len(arr)
for i in range(n - 2, -1, -1):
	if arr[i] <= arr[i + 1] + k:
		arr[i + 1] = -1
ans = [0 for i in range(1000001)]
for i in arr:
	if i != -1:
		ans[i] += 1
an = []
for i in brr:
	if ans[i] != 0:
		an.append(i)
print(len(an))


(n, K) = map(int, input().split(' '))
L = list(map(int, input().split(' ')))
total = 0
L.sort()
i = 0
while i < len(L):
	skip = 1
	can_swallow = False
	for j in range(i + 1, len(L)):
		if L[i] == L[j]:
			skip += 1
			continue
		if L[j] <= L[i] + K:
			can_swallow = True
		break
	if can_swallow:
		total += skip
	i += skip
print(n - total)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
count = 0
tracker = [1] * n
for i in range(n - 1):
	if arr[i] < arr[i + 1] <= arr[i] + k:
		count += tracker[i]
	elif arr[i] == arr[i + 1]:
		tracker[i + 1] += tracker[i]
answer = n - count
print(answer)


(n, k) = list(map(int, input().split()))
bact = list(map(int, input().split()))
bact.sort()
res = 0
live = 1
for i in range(n - 1):
	if bact[i + 1] == bact[i]:
		live += 1
	elif bact[i + 1] - bact[i] > k:
		res += live
		live = 1
	else:
		live = 1
res += live
print(res)


(n, K) = map(int, input().split())
bac = list(map(int, input().split()))
bac.sort()
diff = [0 for i in range(n - 1)]
count = 0
future = 0
for i in range(n - 1):
	if count == 0 and bac[i + 1] - bac[i] != 0:
		diff[i] = bac[i + 1] - bac[i]
	elif count > 0:
		diff[i] = future
		count -= 1
	else:
		j = i
		tmp = bac[j]
		j = j + 1
		while bac[j] == tmp and j < n - 1:
			j += 1
		future = bac[j] - bac[i]
		diff[i] = future
		count = j - i - 1
swallow = 0
for i in range(n - 1):
	if diff[i] <= K and diff[i] != 0:
		swallow += 1
print(n - swallow)


import math
q = 1
for _ in range(q):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	arr = [0] * (10 ** 6 + 1)
	for i in range(n):
		arr[l[i]] += 1
	ans = n
	l = list(set(l))
	l.sort()
	i = len(l) - 1
	while i > 0:
		if l[i] > l[i - 1] and l[i] - l[i - 1] <= k:
			ans -= arr[l[i - 1]]
		i -= 1
	print(ans)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
d = {i: 0 for i in range(1000005)}
for i in a:
	d[i] += 1
cnt = n
for i in range(n - 1):
	if a[i + 1] > a[i] and a[i + 1] <= a[i] + k:
		cnt -= d[a[i]]
print(cnt)


while True:
	try:
		(l, k) = map(int, input().split())
		a = list(map(int, input().split()))
		j = 0
		cunt = 0
		a.sort()
		for el in a:
			while el > a[j]:
				if el > a[j] and a[j] + k >= el:
					cunt += 1
				j += 1
		print(l - cunt)
	except EOFError:
		break


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dic = get_frequency(a)
ss = sorted(list(set(a)))
tobesubtracttion = 0
for i in range(len(ss) - 1):
	if ss[i + 1] <= ss[i] + k:
		tobesubtracttion += dic[ss[i]]
print(n - tobesubtracttion)


(n, K) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
(cnt, ans) = (0, 0)
for i in range(1, n):
	if x[i] - x[i - 1] <= K and x[i] > x[i - 1]:
		ans += 1 + cnt
		cnt = 0
	elif x[i] == x[i - 1]:
		cnt += 1
	elif x[i] > x[i - 1] + K:
		cnt = 0
print(n - ans)


(stfn, stfk) = input().split()
(n, K) = (int(stfn), int(stfk))
array = [int(s) for s in input().split()]
array = sorted(array)
hmap = dict()
ar = [array[0]]
for j in array:
	if j != ar[-1]:
		ar.append(j)
	if j in hmap:
		hmap[j] += 1
	else:
		hmap[j] = 1
arr = []
i = 0
while i < len(ar) - 1:
	if not (ar[i + 1] > ar[i] and ar[i + 1] <= ar[i] + K):
		arr.append(ar[i])
	i += 1
arr.append(ar[-1])
additLength = 0
for j in arr:
	if j in hmap:
		additLength += hmap[j] - 1
print(len(arr) + additLength)


from bisect import *
from collections import defaultdict
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
hash = defaultdict(int)
for i in l:
	hash[i] += 1
la = list(set(l))
la.sort()
count = 0
yo = set()
for (j, i) in enumerate(la):
	z1 = len(la) - j - 1
	if z1 > 0:
		if i + k in hash:
			yo.add(j)
			count += 1
			continue
		else:
			z2 = bisect_right(la, i + k)
			if z2 > j + 1:
				yo.add(j)
				count += 1
ans = 0
for i in range(len(la)):
	if i not in yo:
		ans += hash[la[i]]
print(ans)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
size = input().split(' ')
for i in range(n):
	size[i] = int(size[i])
size.sort()
count = n
j = 0
num = 0
for i in range(n):
	while size[i] > size[j] + k:
		j += 1
	if i == j:
		num = 0
	if size[i] > size[j]:
		count -= num
		j = i
		num = 1
	else:
		num += 1
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
i = 0
c = 0
for q in a:
	while q > a[i]:
		if a[i] + k >= q:
			c += 1
		i += 1
print(n - c)


(n, k) = [int(x) for x in input().split()]
s = sorted([int(x) for x in input().split()], reverse=1)
ans = 1
l = s[0]
for i in range(1, n):
	if not (abs(s[i] - s[i - 1]) <= k and s[i] < l):
		ans += 1
		l = s[i]
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a += [a[-1] + k + 1]
a = [a[0]] + a
o = 0
c = 1
for i in range(1, n + 1):
	if a[i] != a[i - 1]:
		c = 1
	if a[i] + k < a[i + 1]:
		o += c
		c = 1
	elif a[i] == a[i + 1]:
		c += 1
print(o)


(n, k) = [int(n) for n in input().split()]
b_sizes = [int(n) for n in input().split()]
b_d = {}
b_s_u = []
deaths = 0
for i in b_sizes:
	if i in b_d:
		b_d[i] += 1
	else:
		b_d[i] = 1
		b_s_u.append(i)
b_s_u.sort()
for j in range(len(b_s_u) - 1):
	if b_s_u[j] < b_s_u[j + 1] and b_s_u[j + 1] <= b_s_u[j] + k:
		deaths = deaths + b_d[b_s_u[j]]
print(n - deaths)


(n, k) = map(int, input().split())
bacteria = list(map(int, input().split()))
bacteria.sort()
previous_bacterium = bacteria[0]
same_bacteria = 0
for bacterium in bacteria[1:]:
	if bacterium > previous_bacterium:
		if bacterium - previous_bacterium <= k:
			n -= same_bacteria + 1
		same_bacteria = 0
	else:
		same_bacteria += 1
	previous_bacterium = bacterium
print(n)


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
(n, K) = rint()
a = list(rint())
a.sort()
cnt = 0
cnt_same = 1
for i in range(n - 1):
	if a[i + 1] == a[i]:
		cnt_same += 1
		continue
	if a[i + 1] - a[i] <= K:
		cnt_same = 1
		continue
	else:
		cnt += cnt_same
		cnt_same = 1
print(cnt + cnt_same)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = 0
i = 0
while i < n - 1:
	j = i + 1
	while j < n and l[j] == l[i]:
		j += 1
	if j == n:
		break
	elif l[j] <= l[i] + k:
		a += j - i
	i = j
print(n - a)


import sys
from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split(' '))
arr = list(map(int, stdin.readline().split(' ')))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = n
arr.sort()
ctr = 0
for i in range(1, len(arr)):
	if arr[i] > arr[i - 1] and arr[i] <= k + arr[i - 1]:
		ans -= d[arr[i - 1]]
print(ans)


(n, k) = map(int, input().strip().split(' '))
a = list(map(int, input().strip().split(' ')))
a.sort()
q = 0
t = 1
if n == 1:
	print(1)
else:
	for i in range(1, n):
		if a[i] == a[i - 1]:
			t += 1
		elif a[i] <= a[i - 1] + k:
			q += t
			t = 1
		else:
			t = 1
	print(len(a) - q)


(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
s.sort()
s.reverse()
x = 0
ans = 0
y = 1
while x < n and y < n:
	while x < n and y < n and (s[x] > s[y]) and (s[x] <= s[y] + k):
		ans += 1
		y += 1
	if x == y - 1:
		x = y
		y += 1
	else:
		x = y - 1
print(n - ans)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
y = 0
d = 0
for i in range(n - 1):
	if x[i + 1] > x[i] and x[i + 1] <= x[i] + k:
		y += 1 + d
		d = 0
	if x[i + 1] == x[i]:
		d += 1
	if x[i + 1] != x[i]:
		d = 0
print(n - y)


(n, k) = [int(i) for i in input().split()]
(a, j) = (sorted([int(i) for i in input().split()]), 0)
for i in a:
	while i > a[j]:
		if i <= a[j] + k:
			n -= 1
		j += 1
print(n)


(n, m) = map(int, input().split())
(l, j) = (sorted(map(int, input().split())), 0)
for (i, a) in enumerate(l):
	while l[j] < a:
		if a <= l[j] + m:
			n -= 1
		j += 1
print(n)


(a, b) = map(int, input().split())
d = dict()
for i in map(int, input().split()):
	d[i] = d.get(i, 0) + 1
z = sorted(d)
for i in range(1, len(z)):
	if z[i - 1] + b >= z[i]:
		d[z[i - 1]] = 0
print(sum(d.values()))


(n, k) = map(int, input().split())
l = sorted(map(int, input().split()))
j = 0
for i in l:
	while l[j] < i:
		if i <= k + l[j]:
			n -= 1
		j += 1
print(n)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
d = [0 for i in range(max(a) + 1)]
vis = {}
for i in a:
	d[i] += 1
a = list(set(a))
a.sort()
m = len(a)
i = 1
c = 0
while i < m:
	while i < m and a[i] - a[i - 1] <= k:
		vis[a[i - 1]] = 1
		i += 1
	i += 1
for i in vis:
	n -= d[i]
print(n)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
visit = [0 for i in range(n)]
i = 0
j = 1
dele = 0
while i < n and j < n:
	if visit[i] == 1:
		continue
	elif i == j:
		j = j + 1
		continue
	elif a[j] <= a[i] + k and a[i] < a[j]:
		dele += 1
		visit[i] = 1
		i += 1
	elif a[i] == a[j]:
		j += 1
		continue
	else:
		i += 1
print(n - dele)


import bisect

def solve(n, k, A):
	A.sort()
	pos = n - 1
	ret = 0
	while pos >= 0:
		while pos > 0 and A[pos] == A[pos - 1]:
			pos -= 1
		idx = bisect.bisect_left(A, A[pos] - k)
		ret += pos - idx
		if A[idx] == A[pos]:
			pos -= 1
		else:
			pos = idx
	return n - ret

def driver():
	inp = [*map(lambda x: int(x), input().split())]
	(n, k) = (inp[0], inp[1])
	A = [*map(lambda x: int(x), input().split())]
	print(solve(n, k, A))
driver()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
result = n
trailing = 0
for i in range(1, n):
	while a[trailing] < a[i]:
		if a[trailing] + k >= a[i]:
			result -= 1
		trailing += 1
print(result)


a = [int(q) for q in input().strip().split()]
b = [int(q) for q in input().strip().split()]
c = list(set(b))
b.sort()
c.sort()
t = 0
ct = 0
d = []
u = b[0]
for k in range(len(b)):
	if u != b[k]:
		u = b[k]
		t += 1
	if t == len(c) - 1:
		ct += 1
		continue
	if c[t] + a[1] < c[t + 1]:
		ct += 1
print(ct)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
j = 0
for a in l:
	while l[j] < a:
		if a <= l[j] + m:
			n -= 1
		j += 1
print(n)


from bisect import bisect

def main():
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	ans = N
	for i in range(N):
		j = bisect(A, A[i] + K)
		if A[i] < A[j - 1]:
			ans -= 1
	print(ans)
main()


(n, K) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
s = []
for a in A:
	if not s:
		s.append(a)
		continue
	while s:
		if a - K <= s[-1] < a:
			s.pop()
		else:
			break
	s.append(a)
print(len(s))


import sys
input = sys.stdin.readline
(n, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
x = 0
b = a[0]
for i in range(1, n):
	if a[i] == b:
		x += 1
	elif a[i] > b and b + K >= a[i]:
		b = a[i]
		x = 0
	else:
		b = a[i]
		ans += x + 1
		x = 0
print(ans + x + 1)


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
a.append(2 * 10 ** 9)
(ans, z) = (0, 0)
for i in range(n):
	while z < n and a[i] == a[z]:
		z += 1
	if a[z] - a[i] > k:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
d = {ls[0]: 1}
i = 1
l1 = [ls[0]]
while i < n:
	if ls[i] > ls[i - 1]:
		l1.append(ls[i])
		d[ls[i]] = 1
	else:
		d[ls[i]] += 1
	i += 1
l2 = [i - k for i in l1]
i = 0
j = 1
dec = 0
while i < len(l1) and j < len(l2):
	if i == j:
		j += 1
	elif l1[i] >= l2[j]:
		dec += 1 * d[l1[i]]
		i += 1
	else:
		i += 1
print(n - dec)


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
ai.sort()
last = ai[n - 1]
ans = 1
lastAlive = ai[n - 1]
for i in range(n - 2, -1, -1):
	if last - k > ai[i] or lastAlive == ai[i]:
		ans += 1
		lastAlive = ai[i]
	last = ai[i]
print(ans)


import copy
(n, k) = list(map(int, input().split()))
li = list(map(int, input().split()))
stack = copy.deepcopy(li)
stack.sort(reverse=True)
for i in range(len(li)):
	li[i] = li[i] + k
li.sort()
ans = n
i = 0
while i < n and len(stack) > 0:
	po = len(stack) - 1
	while len(stack) > 0 and li[i] - k == stack[po]:
		stack.pop()
		po = len(stack) - 1
	if len(stack) > 0 and stack[po] <= li[i]:
		i = i + 1
		ans = ans - 1
	elif len(stack) > 0 and stack[po] > li[i]:
		i = i + 1
print(ans)


(n, K) = map(int, input().split())
b = sorted([int(x) for x in input().split()])
l = cur = 0
for i in range(1, n):
	if b[i] == b[i - 1]:
		continue
	if b[i] > b[i - 1] + K:
		l = i
	else:
		cur += i - l
		l = i
print(n - cur)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
b = 0
tb = 1
for i in range(n - 1):
	if a[i + 1] - a[i] <= k and a[i + 1] > a[i]:
		b = b + tb
		tb = 1
	elif a[i + 1] == a[i]:
		tb += 1
	elif a[i + 1] != a[i]:
		tb = 1
print(n - b)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
rem = set()
arr = sorted(arr)
l = 0
for i in range(1, n):
	if arr[i] == arr[i - 1]:
		l += 1
	if arr[i] > arr[i - 1] and arr[i - 1] + k >= arr[i]:
		rem.add(arr[i - 1])
print(n - sum((x in rem for x in arr)))


(n, k) = map(int, input().split())
a = sorted([int(x) for x in input().split()])
small = a[0]
n_small = 1
ans = n
for i in range(1, n):
	if a[i] > small:
		if a[i] - small <= k:
			ans -= n_small
		n_small = 1
		small = a[i]
	else:
		n_small += 1
print(ans)


(n, K) = map(int, input().split())
lst = [int(x) for x in input().split()]
p = []
d = {}
for x in lst:
	if not x in d:
		d[x] = 0
		p.append(x)
	d[x] += 1
p.sort()
k = 0
for x in range(1, len(p)):
	if p[x] > p[x - 1] and p[x] <= p[x - 1] + K:
		k += d[p[x - 1]]
print(n - k)


R = lambda : list(map(int, input().split()))
(n, k) = R()
a = sorted(R())
st = 0
en = 0
for i1 in range(len(a)):
	if i1 == n - 1:
		break
	if (a[i1] < a[i1 + 1]) * (a[i1] >= a[i1 + 1] - k):
		for i2 in range(st, en + 1):
			a[i2] = -1
	if a[i1] == a[i1 + 1]:
		en = i1 + 1
	else:
		st = i1 + 1
		en = i1 + 1
print(n - a.count(-1))


(n, K) = map(int, input().split())
a = sorted(list(map(int, input().split())))
num = 0
for i in a:
	while a[num] < i:
		if i <= K + a[num]:
			n -= 1
		num += 1
print(n)


line = list(map(int, input().split()))
n = line[0]
k = line[1]
a = list(map(int, input().split()))
freq = {}
for x in a:
	if x in freq:
		freq[x] += 1
	else:
		freq[x] = 1
a = list(set(a))
a.sort()
for i in range(len(a) - 1):
	if a[i + 1] <= a[i] + k:
		n -= freq[a[i]]
print(str(n))


import os, sys, math
from bisect import *

def main():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	ans = 1
	eat_till = a[0] - k
	dont_eat = a[0]
	for x in a[1:]:
		debug('current: ', x, ' ... eating between [', dont_eat - 1, ',', eat_till, '], current ans:', ans, end=' ')
		if dont_eat > x >= eat_till:
			debug('eaten')
			eat_till = x - k
		else:
			ans += 1
			debug('added')
			eat_till = x - k
			dont_eat = x
	print(ans)

def debug(*args, **kwargs):
	if 'DEBUG' in os.environ:
		print(*args, **kwargs)
main()


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
arr.append(10 ** 7)
ans = 0
j = 0
for i in range(n):
	while j < n and arr[i] == arr[j]:
		j += 1
	if arr[j] - arr[i] > k:
		ans += 1
print(ans)


(n, k) = tuple(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a = sorted(a, reverse=True)
index = 0
count = 0

def sec(aj, ai):
	return aj < ai and aj >= ai - k

def bSearch(iai, a):
	if iai == len(a) - 1:
		return None
	if not sec(a[iai + 1], a[iai]):
		return False
	high = len(a)
	low = iai
	while low < high - 1:
		mid = (high + low) // 2
		if sec(a[mid], a[iai]):
			low = mid
		else:
			high = mid
	return low
while index < len(a) - 1:
	mid = bSearch(index, a)
	if mid == False:
		index += 1
		count += 1
	else:
		index += mid - index
print(count + 1)


line1 = input()
line2 = input()
line1 = line1.split(' ')
line2 = line2.split(' ')
line2 = [int(x) for x in line2]
n = int(line1[0])
k = int(line1[1])
a = {}
for i in line2:
	if i not in a:
		a[i] = 1
	else:
		a[i] = a[i] + 1
b = list(a.keys())
b.sort()
for j in range(len(b) - 1):
	if b[j] < b[j + 1] and b[j + 1] <= b[j] + k:
		a[b[j]] = 0
c = list(a.values())
s = sum(c)
print(s)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a)
count = 0
countRep = 0
freq = {}
for i in a:
	freq[i] = 0
for i in range(len(a)):
	freq[a[i]] += 1
a = sorted(list(set(a)))
for i in range(len(a) - 1):
	if a[i + 1] <= a[i] + k:
		count += freq[a[i]]
print(n - count)


(n, k) = map(int, input().split())
lis = sorted(map(int, input().split()))
ans = 0
c = 1
for i in range(0, n - 1):
	if lis[i] == lis[i + 1]:
		c += 1
	else:
		if lis[i] + k >= lis[i + 1]:
			ans += c
		c = 1
print(n - ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = n
j = 1
for i in range(n - 1):
	while j + 1 < n and a[i] == a[j]:
		j += 1
	if a[i] < a[j] and a[i] + k >= a[j]:
		ans -= 1
print(ans)


from math import *
a = input().split()
mass = input().split()
for i in range(len(mass)):
	mass[i] = int(mass[i])
mass = sorted(mass)
ans = len(mass)
sub = 1
for i in range(1, len(mass)):
	if mass[i] > mass[i - 1] and mass[i] <= mass[i - 1] + int(a[1]):
		ans -= sub
		sub = 1
		continue
	if mass[i] == mass[i - 1]:
		sub += 1
		continue
	sub = 1
print(ans)


import collections
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)
a = list(set(a))
a = sorted(a)
N = len(a)
pre = a[N - 1]
num = c[a[-1]]
for i in range(N - 2, -1, -1):
	if not a[i] < pre <= a[i] + k:
		num += c[a[i]]
	pre = a[i]
print(num)


(n, k) = map(int, input().split())
dic = {}
for item in tuple(map(int, input().split())):
	if item in dic:
		dic[item] += 1
	else:
		dic[item] = 1
a = sorted(tuple(zip(tuple(dic.keys()), tuple(dic.values()))))
for i in range(len(a) - 1):
	if a[i + 1][0] <= a[i][0] + k:
		n -= a[i][1]
print(n)


import sys
import io
stream_enable = 0
inpstream = '\n7 1\n101 53 42 102 101 55 54 101 101 102\n'
if stream_enable:
	sys.stdin = io.StringIO(inpstream)
	input()

def inpmap():
	return list(map(int, input().split()))
(n, k) = inpmap()
arr = inpmap()
arr.sort()
i = 1
x = 1
while i < len(arr):
	if arr[i] == arr[i - 1]:
		x += 1
	elif arr[i] > arr[i - 1] and arr[i] <= arr[i - 1] + k:
		n -= x
		x = 1
	else:
		x = 1
	i += 1
print(n)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import sys
import string
import random
from typing import List
sys.setrecursionlimit(99999)
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
cs = collections.Counter(arr)
ks = list(cs.keys())
ks.sort()
ans = 0
for i in range(1, len(ks)):
	if ks[i] <= ks[i - 1] + k:
		continue
	else:
		ans += cs[ks[i - 1]]
ans += cs[ks[-1]]
print(ans)


import time
(n, K) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
start = time.time()
a.sort()
ans = n
flag = 1
for i in range(1, n):
	if a[i - 1] == a[i]:
		flag += 1
	elif a[i] <= a[i - 1] + K:
		ans -= flag
		flag = 1
	else:
		flag = 1
print(ans)
finish = time.time()


inp = input()
(n, k) = inp.split()
(n, k) = (int(n), int(k))
a = input()
a = [int(i) for i in a.split()]
a.sort()
(i, j, ans) = (n - 1, n - 2, 0)
while i >= 0 and j >= 0:
	if a[i] <= a[j] + k and a[i] > a[j]:
		ans += 1
		j -= 1
	elif i - 1 == j:
		i = i - 1
		j = j - 1
	else:
		i -= 1
print(n - ans)


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
import math
cin = stdin.readline

def cout(x):
	stdout.write(str(x) + '\n')

def nexint():
	return int(stdin.readline())

def readline():
	return map(int, stdin.readline().split())

def readlist():
	return list(map(int, stdin.readline().split()))

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError
(n, k) = readline()
arr = readlist()
arr.sort()
count = 0
for x in arr:
	ix = bisect_right(arr, x)
	if ix != len(arr) and x < arr[ix] <= x + k:
		count += 1
cout(n - count)


def go():
	(n, k) = (int(i) for i in input().split(' '))
	a = sorted([int(i) for i in input().split(' ')], reverse=True)
	if len(a) == 1:
		return 1
	to_remove = 0
	i = 0
	while n > i + 1:
		if a[i] > a[i + 1] and a[i] <= a[i + 1] + k:
			to_remove += 1
			if i + 2 < n and a[i + 1] == a[i + 2]:
				i += 1
				while i + 1 < n and a[i] == a[i + 1]:
					to_remove += 1
					i += 1
					found = True
				if found:
					i -= 1
		i += 1
	return n - to_remove
print(go())


(n, k) = map(int, input().split())
u = list(map(int, input().split()))
u.sort()
eat = 0
ans = n
m = 0
for i in range(n):
	if eat == 0:
		eat = u[i]
		m = 1
		continue
	if u[i] > eat + k:
		eat = u[i]
		m = 1
	elif u[i] == eat:
		m += 1
	else:
		ans -= m
		eat = u[i]
		m = 1
print(ans)


import sys, string
(n, k) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
arr.sort()
st = []
for i in arr:
	if not st:
		st.append(i)
	else:
		while st:
			if 0 < abs(st[-1] - i) <= k:
				st.pop()
			else:
				break
		st.append(i)
print(len(st))


(n, k) = input().split()
(n, k) = (int(n), int(k))
d = {}
arr = list(map(int, input().split()))
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
arr = list(set(arr))
arr.sort()
cnt = 0
for i in range(len(arr) - 1):
	if arr[i] + k >= arr[i + 1]:
		cnt += d[arr[i]]
print(n - cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
(slow, fast) = (0, 0)
while fast < n:
	if a[slow] == a[fast]:
		fast += 1
	elif abs(a[slow] - a[fast]) <= k:
		a[slow] = 0
		slow += 1
	else:
		slow += 1
ans = 0
for i in a:
	if i != 0:
		ans += 1
print(ans)


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a = sorted(a, reverse=True)
count = 0
l = a[0]
for j in range(1, n):
	if a[j] + k >= a[j - 1] and a[j] < l:
		count = count + 1
	else:
		l = a[j]
print(n - count)


TN = 1

def solution():
	(n, K) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	ans = 0
	for i in range(1, len(a)):
		if a[i] > a[i - 1] and a[i] <= a[i - 1] + K:
			j = i - 1
			while j >= 0 and a[j] == a[i - 1]:
				ans += 1
				j -= 1
	print(n - ans)
while TN != 0:
	solution()
	TN -= 1


from bisect import bisect_left as bs
(n, k) = [int(_) for _ in input().strip().split()]
arr = [int(_) for _ in input().strip().split()]
arr.sort()
l = []
for i in range(n):
	if len(l) == 0:
		l.append(arr[i])
	else:
		while len(l) > 0 and l[-1] + k >= arr[i] and (l[-1] < arr[i]):
			l.pop()
		l.append(arr[i])
print(len(l))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
d = {}
for i in l:
	try:
		d[i] += 1
	except:
		d.update({i: 0})
		d[i] += 1
(i, j, c) = (1, 0, 0)
while True:
	if i >= n or j >= n:
		break
	if l[i] > l[j] and l[i] <= l[j] + k:
		c += d[l[j]]
	i += 1
	j += 1
print(n - c)


(n, k) = map(int, input().split())
arr = map(int, input().split())
arr = sorted(arr)
s = 1
cyprus = 0
for i in range(1, arr.__len__()):
	if arr[i] == arr[i - 1]:
		s += 1
	else:
		if arr[i] - arr[i - 1] <= k:
			n -= s
		s = 1
print(n)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
answer = 0
dct = {}
for i in a:
	if i in dct:
		dct[i] += 1
	else:
		dct[i] = 1
a = list(set(a))
a.sort()
for i in range(len(a) - 1):
	if a[i + 1] > a[i] + k:
		answer += dct[a[i]]
print(answer + dct[a[-1]])


(n, k) = map(int, input().split())
bac = [int(i) for i in input().split()]
bac.sort()
same = 1
for i in range(n - 1):
	if bac[i] == bac[i + 1]:
		same += 1
	elif bac[i] < bac[i + 1] <= bac[i] + k:
		n -= same
		same = 1
	else:
		same = 1
print(n)


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
i = 0
lh = [True for i in range(n)]
while i < n - 1:
	j = i + 1
	c = 0
	while j < n and l[i] > l[j] and (l[i] <= l[j] + k):
		lh[j] = False
		j += 1
		c += 1
	if c == 0:
		i = j
		continue
	i = j - 1
print(lh.count(True))


import collections
from functools import cmp_to_key
import sys

def getIntList():
	return list(map(int, input().split()))
(n, K) = getIntList()
z = getIntList()
z.sort()
res = 0
last = -1
lastc = 0
for x in z:
	if x == last:
		lastc += 1
	elif last + K >= x:
		last = x
		lastc = 1
	else:
		res += lastc
		last = x
		lastc = 1
res += lastc
print(res)


import sys
(n, K) = list(map(int, sys.stdin.readline().split()))
a = sorted(list(map(int, sys.stdin.readline().split())))
eaten = set()
for i in range(1, n):
	(x, y) = (a[i - 1], a[i])
	if y > x and y <= x + K:
		eaten.add(x)
print(n - sum((x in eaten for x in a)))


(n, k) = map(int, input().split())
t = list(map(int, input().split()))
t.sort()
f = {}
for j in t:
	if j not in f:
		f[j] = 1
	else:
		f[j] += 1
p = 0
for j in range(n):
	if j < n - 1:
		if t[j + 1] > t[j] and t[j] + k >= t[j + 1]:
			p += f[t[j]]
print(n - p)


def binarySearch(n, i, k, a):
	l = i + 1
	u = n - 1
	ans = 0
	while l <= u:
		mid = int((l + u) / 2)
		if a[mid] == a[i]:
			l = mid + 1
		elif a[mid] - a[i] <= k:
			ans = 1
			break
		else:
			u = mid - 1
	return ans
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
visited = []
for i in range(0, n):
	visited.append(0)
i = 0
j = 1
ctr = 0
for i in range(0, n):
	val = binarySearch(n, i, k, a)
	ctr += val
print(n - ctr)


(n, m) = map(int, input().split())
l = sorted(map(int, input().split()))
(t, b) = (l[::-1], -m)
for a in l:
	while b < a:
		if a <= b + m:
			n -= 1
		b = t.pop()
print(n)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, k) = LI()
	a = collections.Counter(LI())
	r = n
	ks = sorted(a.keys())
	for i in range(len(ks) - 1):
		k1 = ks[i]
		k2 = ks[i + 1]
		if k1 < k2 and k1 + k >= k2:
			r -= a[k1]
	return r
print(main())


(n, k) = map(int, input().split())
bacterias = {}
for el in list(map(int, input().split())):
	if el not in bacterias.keys():
		bacterias.update({el: [1, 1]})
	else:
		bacterias[el][0] += 1
bacterias_weights = list(bacterias.keys())
bacterias_weights.sort()
for j in range(len(bacterias_weights)):
	for i in range(j, len(bacterias_weights)):
		if bacterias_weights[i] > bacterias_weights[j] + k:
			break
		if bacterias_weights[j] < bacterias_weights[i] <= bacterias_weights[j] + k:
			bacterias[bacterias_weights[j]][1] = 0
			break
count = 0
for bacteria in bacterias.keys():
	if bacterias[bacteria][1]:
		count += bacterias[bacteria][0]
print(count)


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
data = data[::-1]
ans = 1
prev = data[0]
for i in range(1, n):
	if not (data[i] != prev and data[i] + k >= prev):
		ans += 1
	if i < n - 1 and data[i] == data[i + 1]:
		prev = prev
	else:
		prev = data[i]
print(ans)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
peso = [1] * n
s.sort()
cont = 0
for i in range(n - 1):
	if s[i] < s[i + 1] and s[i + 1] <= s[i] + k:
		cont += peso[i]
	elif s[i] == s[i + 1]:
		peso[i + 1] += peso[i]
print(len(s) - cont)


from bisect import bisect_right
(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
	p = bisect_right(a, a[i] + k)
	if p <= n - 1:
		if a[p - 1] > a[i] and a[p - 1] - a[i] <= k or (a[p] > a[i] and a[p] - a[i] <= k):
			ans += 1
	elif p == n:
		if a[p - 1] > a[i] and a[p - 1] - a[i] <= k:
			ans += 1
print(n - ans)


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split()), reverse=True))
cnt = 0
(i, j) = (1, 0)
while i < n:
	if a[i] == a[j]:
		i += 1
		j += 1
	elif a[i] < a[j] <= a[i] + k:
		cnt += 1
		i += 1
	elif a[j] > a[i] + k:
		j += 1
		if j == i:
			i += 1
print(len(a) - cnt)


(n, k) = input().split()
k = int(k)
l = input().split()
l = list(map(int, l))
l.sort()
n = int(n)
f = l[0]
arr = []
mat = []
c = 0
for i in range(len(l)):
	if l[i] == f:
		c = c + 1
	else:
		mat.append(c)
		arr.append(f)
		f = l[i]
		c = 1
arr.append(f)
mat.append(c)
for i in range(1, len(arr)):
	if arr[i] - arr[i - 1] <= k:
		n = n - mat[i - 1]
print(n)


import sys
from collections import Counter

def main():
	(n, K) = map(int, sys.stdin.readline().split())
	l = list(map(int, sys.stdin.readline().split()))
	c = Counter(l)
	l = sorted(list(set(l)))
	last = l[-1]
	(res, r) = ([], 0)
	for i in range(len(l) - 1):
		if l[i] + K < l[i + 1]:
			res.append(l[i])
	res.append(last)
	for i in res:
		r += c[i]
	print(r)
main()


(n, k) = list(map(int, input().split()))
n1 = n
a = list(map(int, input().split()))
a.sort()
j = 0
for i in range(n):
	while a[j] < a[i]:
		if a[i] <= a[j] + k:
			n1 -= 1
		j += 1
print(n1)


import math
(n, k) = map(int, input().split(' '))
sizes = list(map(int, input().split(' ')))
sizes.sort(reverse=True)
sizes.append(-math.inf)
count = 0
start = 0
while start < n:
	length = 1
	while sizes[start + length - 1] <= sizes[start + length] + k and sizes[start] > sizes[start + length]:
		length += 1
	count += 1
	start += length
print(count)


(n, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = n
cnt = 1
for i in range(n - 1):
	if a[i + 1] == a[i]:
		cnt += 1
	else:
		if a[i + 1] <= a[i] + K:
			ans -= cnt
		cnt = 1
print(ans)


(n, k) = list(map(int, input().split()))
last = 10000000
res = 0
cur_res = 1
for cur in sorted(list(map(int, input().split()))):
	if cur == last:
		cur_res += 1
	else:
		if cur > last + k:
			res += cur_res
		cur_res = 1
	last = cur
res += cur_res
print(res)


(n, K) = map(int, input().split())
counts = {}
indi = set()
for s in map(int, input().split()):
	counts[s] = counts.get(s, 0) + 1
	indi.add(s)
sizes = list(indi)
sizes.sort()
i = 0
while i < len(sizes):
	if i + 1 < len(sizes) and sizes[i] < sizes[i + 1] and (sizes[i] + K >= sizes[i + 1]) and (counts[sizes[i]] != 1):
		counts[sizes[i]] = 1
	else:
		i += 1
i = 0
while i < len(sizes):
	if i + 1 < len(sizes) and sizes[i] < sizes[i + 1] and (sizes[i] + K >= sizes[i + 1]) and (counts[sizes[i]] != 0):
		counts[sizes[i]] = 0
	else:
		i += 1
counting = 0
for key in counts.keys():
	counting += counts[key]
print(counting)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
(r, l) = (0, 1)
for i in range(1, n):
	if a[i] == a[i - 1]:
		l += 1
	elif a[i] - a[i - 1] <= k:
		r += l
		l = 1
	else:
		l = 1
print(n - r)


def getIntList():
	return list(map(int, input().split()))
(n, K) = getIntList()
a = getIntList()
a.sort()
result = n
curr = a[-1]
for i in range(n - 1, -1, -1):
	if curr - K <= a[i] < curr:
		result -= 1
	if i > 0 and a[i - 1] != a[i]:
		curr = a[i]
print(result)


from copy import deepcopy
import collections
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	d[i] = 0
for i in arr:
	d[i] += 1
arr = list(d.keys())
arr.sort()
count = 0
for i in range(len(arr) - 1):
	if arr[i + 1] - arr[i] <= k:
		count += d[arr[i]]
print(n - count)


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
s = input().split()
s = list(map(int, s))
d = dict()
for i in s:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
s = list(d.keys())
s.sort()
pred = s[0]
for i in range(1, len(s)):
	tec = s[i]
	if tec <= pred + k:
		n -= d[pred]
	pred = tec
print(n)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
a.append(10000000)
s = 0
i = 0
j = 0
while i < len(a) - 1:
	while j < len(a) and a[j] == a[i]:
		j += 1
	if a[j] - a[i] > k:
		s += 1
	i += 1
print(s)


from collections import Counter

def i_ints():
	return list(map(int, input().split()))
(n, K) = i_ints()
a = i_ints()
a = sorted(Counter(a).items())
a.append((a[-1][0] + K + 1, 0))
count = 0
for i in range(len(a) - 1):
	if a[i][0] + K < a[i + 1][0]:
		count += a[i][1]
print(count)


(n, k) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
i = 0
j = 1
l.sort()
le = len(l)
deletion = 0
valid = [0 for i in range(le)]
while j < le and i < le:
	if valid[i] == 1:
		i = i + 1
		continue
	elif i == j:
		j = j + 1
		continue
	elif l[i] < l[j] and l[j] <= l[i] + k:
		deletion = deletion + 1
		valid[i] = 1
		i = i + 1
	elif l[i] == l[j]:
		j = j + 1
		continue
	else:
		i = i + 1
print(le - deletion)


(n, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
k = len(a)
i = 0
while i < len(a):
	if a[i] == a[-1]:
		break
	j = i + 1
	while a[i] == a[j]:
		j += 1
	if a[i] + K >= a[j]:
		k -= j - i
	i = j
print(k)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
(n, k) = I()
a = list(I())
a.sort()
d = {}
for x in a:
	d[x] = d.get(x, 0) + 1
ans = 0
for i in range(1, n):
	if a[i] - a[i - 1] <= k and a[i] != a[i - 1]:
		ans += d[a[i - 1]]
print(n - ans)


(n, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
c = 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		c += 1
	elif a[i] <= a[i - 1] + K:
		cnt += c
		c = 1
	else:
		c = 1
print(n - cnt)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
cur_v = a[0]
cur_count = 1
ans = 0
for i in range(1, len(a)):
	if a[i] > a[i - 1] and a[i] > a[i - 1] + k:
		ans += cur_count
		cur_count = 1
	elif a[i] == a[i - 1]:
		cur_count += 1
	elif a[i] > a[i - 1]:
		cur_count = 1
ans += cur_count
print(ans)


from collections import Counter
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
d = Counter(lis)
lis = list(set(lis))
lis.sort()
counter = 1
for i in range(len(lis) - 1):
	if lis[i] + k >= lis[i + 1] and lis[i] < lis[i + 1]:
		counter += d[lis[i]]
print(n - counter + 1)


R = lambda : map(int, input().split())
(n, m) = R()
r = sorted(list(R()))
s = 1
a = r[0]
c = 0
for i in r[1:]:
	if i == a:
		c += 1
	else:
		if i - a <= m:
			pass
		else:
			s += c + 1
		c = 0
	a = i
print(s + c)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
ans = n
c = 1
for i in range(0, n - 1):
	if a[i] == a[i + 1]:
		c += 1
	elif a[i] + k >= a[i + 1]:
		ans -= c
		c = 1
	else:
		c = 1
print(ans)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a, reverse=True)
eat = [k] * n
i = 1
current = 0
l = len(a)
ans = 1
while current < l and i < l:
	if a[i] < a[current] <= a[i] + eat[current]:
		eat[current] = k + (a[current] - a[i])
		i += 1
	else:
		current = i
		i += 1
		ans += 1
print(ans)


def verify(arr, val, ind):
	while ind != -1 and arr[ind] == val:
		arr[ind] = -1
		ind = ind - 1
inp = input('')
il = inp.split()
[n, k] = [int(il[0]), int(il[1])]
bacsizes = input('')
bsl = bacsizes.split()
for i in range(0, len(bsl)):
	bsl[i] = int(bsl[i])
bsl.sort(key=None, reverse=False)
for i in range(1, len(bsl)):
	u = bsl[i] - bsl[i - 1]
	if u <= k and u != 0:
		verify(bsl, bsl[i - 1], i - 1)
count = 0
for bs in bsl:
	if bs != -1:
		count = count + 1
print(count)


import bisect as bi

def le(a, x):
	i = bi.bisect_right(a, x)
	if i:
		return a[i - 1]
	return 0
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in a:
	if le(a, i + k) == i:
		cnt += 1
print(cnt)


(n, k) = map(int, input().split())
a = map(int, input().split())
a = sorted(a)
aj = a[0]
aj_count = 1
count = 0
for ai in a[1:]:
	if aj == ai:
		aj_count += 1
	else:
		if ai <= aj + k:
			count += aj_count
		aj_count = 1
		aj = ai
print(n - count)


(n, K) = [int(i) for i in input().split()]
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a.sort()
i = 0
j = 1
ans = n
while True:
	if j == n:
		break
	if a[j] == a[i]:
		j += 1
	elif a[i] + K >= a[j]:
		ans -= 1
		i += 1
	else:
		i += 1
print(ans)


s = input().split()
(n, K) = (int(s[0]), int(s[1]))
d = input().split()
d = [int(i) for i in d]
d.sort()
c = 0
for i in range(n - 1):
	if d[i + 1] - d[i] <= K and d[i + 1] > d[i]:
		c += 1
		if i > 0:
			if d[i] == d[i - 1]:
				j = i - 1
				while d[j] == d[i]:
					j -= 1
					c += 1
		continue
print(n - c)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
dd = [0] * 1000001
for i in x:
	c = max(0, i - k)
	dd[c] += 1
	dd[i] -= 1
erase = [False] * 1000001
s = 0
for i in range(1000001):
	s += dd[i]
	if s > 0:
		erase[i] = True
ans = 0
for i in x:
	if erase[i]:
		ans += 1
print(n - ans)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
b.sort(reverse=True)
r = 1
v = b[0]
f = True
for x in b[1:]:
	if x == v and f:
		r += 1
		continue
	elif x < v - k:
		r += 1
		f = True
	else:
		f = False
	v = x
print(r)


def lastBacteriaStanding(arr, k, n):
	ans = n
	arr.sort()
	d = 1
	for i in range(0, n - 1):
		curr = arr[i]
		if curr == arr[i + 1]:
			d += 1
		elif arr[i] + k >= arr[i + 1] and arr[i] < arr[i + 1]:
			ans -= d
			d = 1
		else:
			d = 1
	return ans
(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
print(lastBacteriaStanding(arr, k, n))


from bisect import bisect_left
(n, K) = input().split()
(n, K) = (int(n), int(K))
arr = [int(x) for x in input().split()]
eaten = 0
arr.sort()
for i in range(n - 1):
	x = arr[i]
	j = bisect_left(arr, x + 1, i)
	if j < n:
		eaten += x < arr[j] <= x + K
ans = n - eaten
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if n == 1:
	print(1)
else:
	j = 1
	for i in range(1, n):
		if a[i] == a[i - 1]:
			j += 1
		elif a[i] in range(a[i - 1] + 1, a[i - 1] + k + 1):
			n -= j
			j = 1
		else:
			j = 1
	print(n)


def main():
	(n, k) = map(int, input().split())
	content = sorted(map(int, input().split()))
	double = 0
	answer = 1
	if len(content) == 1:
		print(1)
		return
	j = 1
	while j < len(content):
		if content[j] > content[j - 1]:
			if content[j] > content[j - 1] + k:
				answer += double + 1
			double = 0
		elif content[j] == content[j - 1]:
			double += 1
		j += 1
	if double:
		answer += double
	print(answer)
main()


import bisect
(n, k) = map(int, input().strip().split(' '))
list = list(map(int, input().strip().split(' ')))
list.sort()
cnt = 0
for item in list:
	a = bisect.bisect(list, item)
	if a != n and list[a] - item <= k:
		cnt += 1
print(n - cnt)


import sys
import math
import bisect

def solve(A, m):
	n = len(A)
	ans = 0
	A.sort()
	for i in range(n):
		first = bisect.bisect_left(A, A[i] + 1, lo=i + 1)
		last = bisect.bisect_right(A, A[i] + m, lo=i + 1)
		if first == last:
			ans += 1
	return ans

def main():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = solve(A, m)
	print(ans)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = n
t = 0
y = 0
for i in range(n - 1):
	if y < a[i]:
		t = 0
	if a[i + 1] <= a[i] + k and a[i] < a[i + 1]:
		c -= 1 + t
		t = 0
	elif a[i + 1] == a[i]:
		t += 1
		y = a[i]
	n -= 1
print(c)


from collections import Counter
(n, m) = [int(x) for x in input().split()]
arrc = Counter([int(x) for x in input().split()])
arrs = sorted(arrc)[::-1]
cnt = 0
while arrs:
	curr = arrs.pop()
	if not arrs or arrs[-1] > curr + m:
		cnt += arrc[curr]
print(cnt)


(n, k) = map(int, input().split())
a = map(int, input().split())
a = sorted(a)
b = []
for v in a:
	if len(b) == 0:
		b.append([v, 1])
	elif v == b[-1][0]:
		b[-1][1] += 1
	else:
		b.append([v, 1])
cnt = 0
i = 0
p = 1
while i < len(b) - 1:
	if b[i][0] < b[i + 1][0] and b[i][0] + k >= b[i + 1][0]:
		pass
	else:
		cnt += b[i][1]
	i += 1
print(cnt + b[-1][1])


c = input().split()
n = int(c[0])
K = int(c[1])
a = input().split()
for b in range(len(a)):
	a[b] = int(a[b])
a.sort()
dead = 0
same = 0
last_dead = False
for j in range(len(a) - 1):
	i = j + 1
	if same > 0:
		if last_dead:
			dead += 1
		same -= 1
	else:
		while a[i] == a[j] and i < len(a) - 1:
			i += 1
			same += 1
		last_dead = False
		if a[i] <= a[j] + K and (not a[i] == a[j]):
			dead += 1
			last_dead = True
print(len(a) - dead)


(n, k) = map(int, input().split())
hz = [0] * (10 ** 6 + 1)

def increase(x):
	x = int(x)
	hz[x] += 1
	return x
lst = sorted(list(set(list(map(increase, input().split())))))
ans = 0
for i in range(1, len(lst)):
	temp = lst[i - 1] + k
	if lst[i] <= temp:
		ans += hz[lst[i - 1]]
print(n - ans)


(n, k) = map(int, input().split())
aa = list(map(int, input().split()))
c = {}
for i in aa:
	if i not in c:
		c[i] = 1
	else:
		c[i] += 1
i = 0
j = 1
cnt = 0
a = [i for i in c]
a = sorted(a, reverse=True)
n = len(a)
while i < n:
	j = i + 1
	cnt += c[a[i]]
	while j < n and i < n:
		if a[i] <= a[j] + k:
			i += 1
			j += 1
		else:
			break
	i = j
print(cnt)


from sys import *
from collections import Counter
input = stdin.readline
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())
sJoin = lambda a, sep: f'{sep}'.join(a)
arrJoin = lambda a, sep: f'{sep}'.join(map(str, a))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def main():
	(n, k) = lineInput()
	arr = listInput()
	arr = sorted(arr)
	d = Counter(arr)
	c = 0
	for i in range(1, len(arr)):
		if arr[i] > arr[i - 1] and arr[i] <= arr[i - 1] + k:
			d[arr[i - 1]] = 0
	for (i, v) in d.items():
		c += d[i]
	print(c)
main()


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
l.sort()
st = 0
sm = 0
mini = 10 ** 9
ans = 0
f = 0
alive = []
for end in range(n):
	while l[end] - l[st] <= k and l[end] != l[st]:
		st += 1
	while l[end] - l[st] > k:
		alive.append(st)
		st += 1
		f = 1
		ans += 1
for i in range(st + 1, n):
	alive.append(i)
print(len(alive) + 1)


(n, m) = map(int, input().split())
x = [int(q) for q in input().split()]
x = sorted(x)
a = 1
for i in range(n - 1):
	if x[i] == x[i + 1]:
		a += 1
	elif x[i] < x[i + 1] <= x[i] + m:
		n -= a
		a = 1
	else:
		a = 1
print(n)


from sys import stdin, stdout

def ai():
	return list(map(int, input().split()))

def ei():
	return map(int, input().split())

def ip():
	return int(stdin.readline())

def op(ans):
	return stdout.write(str(ans) + '\n')
(n, k) = ei()
li = ai()
li = sorted(li)
ans = n
u = 1
for i in range(n - 1):
	while u + 1 < n and li[i] == li[u]:
		u += 1
	if li[i] < li[u] and li[i] + k >= li[u]:
		ans -= 1
op(ans)


(n, k) = input().split()
(n, k) = [int(n), int(k)]
a = [int(i) for i in input().split()]
a.sort()
i = n - 1
j = n - 2
c = n
while i > 0 and j >= 0:
	if a[i] > a[j]:
		if a[j] + k >= a[i]:
			c -= 1
			j -= 1
			continue
	if i == j:
		j -= 1
		continue
	i -= 1
print(c)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 1
i = 1
while i < len(a):
	if a[i - 1] > a[i]:
		while i < len(a) and a[i] + k >= a[i - 1]:
			i += 1
	i += 1
	if i - 1 < len(a):
		ans += 1
print(ans)


(size, k) = input().split()
size = int(size)
k = int(k)
nums = input().split()
nums = [int(i) for i in nums]
occurances = {i: 0 for i in nums}
for num in nums:
	occurances[num] += 1
ans = []
nums = sorted(occurances.keys())
for i in range(len(nums) - 1):
	if not (nums[i] < nums[i + 1] and nums[i] + k >= nums[i + 1]):
		ans.append(nums[i])
ans.append(nums[-1])
ans_num = 0
for i in ans:
	ans_num += occurances[i]
print(ans_num)


(n, K) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.sort()
cnt = 0
i = 0
while i < len(a):
	ii = i
	while ii < n and a[ii] == a[i]:
		ii += 1
	same = ii - i
	i = ii
	if i < n and a[i - 1] < a[i] and (a[i] <= a[i - 1] + K):
		cnt += same
print(len(a) - cnt)


from collections import Counter
(n, K) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
C = Counter(a)
ans = n
s = sorted(C.keys())
for (i, el) in enumerate(s[1:]):
	if el - s[i] <= K:
		ans -= C[s[i]]
print(ans)


(n, K) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
(eat, skip) = (0, 1)
for i in range(n - 1, 0, -1):
	if a[i] == a[i - 1]:
		skip += 1
	else:
		if a[i] + K >= a[i - 1]:
			eat += skip
		skip = 1
print(n - eat)


(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
totalbacteria = n
dupcount = 1
for i in range(1, n):
	if nums[i] > nums[i - 1] and nums[i] <= nums[i - 1] + k:
		totalbacteria -= dupcount
	if nums[i] == nums[i - 1]:
		dupcount += 1
	else:
		dupcount = 1
print(totalbacteria)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = n
a.sort(reverse=True)
i = 0
while i < n - 1:
	e = a[i]
	f = 0
	while i < n - 1 and e > a[i + 1] and (e <= a[i + 1] + k):
		i += 1
		cnt -= 1
		f = 1
	if not f:
		i += 1
print(cnt)


(n, K) = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
S.reverse()
(k, l) = (0, 1)
for i in range(n - 1, 0, -1):
	if S[i] == S[i - 1]:
		l += 1
	else:
		if S[i] + K >= S[i - 1]:
			k += l
		l = 1
print(n - k)


def read():
	return int(input())

def readlist():
	return list(map(int, input().split()))

def readmap():
	return map(int, input().split())
(N, K) = readmap()
A = readlist()
A.sort()
count = 0
same = 1
for i in range(N - 1):
	if A[i] == A[i + 1]:
		same += 1
	elif A[i + 1] <= A[i] + K:
		count += same
		same = 1
	else:
		same = 1
print(N - count)


import configparser
import math
import sys
input = sys.stdin.readline

def main():
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	cnts = {}
	for i in a:
		if i in cnts:
			cnts[i] += 1
		else:
			cnts[i] = 1
	a = sorted(list(set(a)))
	cnt = 0
	for i in range(1, len(a)):
		if a[i - 1] + k >= a[i] and a[i] > a[i - 1]:
			cnt += cnts[a[i - 1]]
	print(n - cnt)
main()


s = input()
t = input()
arr1 = list(map(int, s.split()))
arr2 = list(map(int, t.split()))
arr2.sort()
arr = []
freq = []
freq.append(1)
arr.append(arr2[0])
for j in range(1, arr1[0]):
	if arr2[j] != arr2[j - 1]:
		arr.append(arr2[j])
		freq.append(1)
	else:
		freq[len(freq) - 1] = freq[len(freq) - 1] + 1
count = arr1[0]
for i in range(0, len(arr) - 1):
	if arr[i + 1] > arr[i] and arr[i + 1] - arr[i] <= arr1[1]:
		count = count - freq[i]
print(count)


from collections import Counter

def main():
	(n, K) = map(int, input().split())
	a = [int(c) for c in input().split()]
	cnt = Counter(a)
	a = sorted(cnt.keys())
	eaten = 0
	for i in range(len(a) - 1):
		if a[i] < a[i + 1] and a[i + 1] - a[i] <= K:
			eaten += cnt[a[i]]
	print(n - eaten)
main()


def main():
	(n, K) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	remained = 1
	i = len(a) - 1
	j = i - 1
	while 0 <= j < i:
		if a[i] - a[j] <= K and a[i] != a[j]:
			k = j - 1
			while k >= 0 and a[k] == a[j]:
				k -= 1
			i = j
			j = k
		else:
			remained += 1
			i = j
			j -= 1
	print(remained)
main()


line1 = input().split()
n = int(line1[0])
k = int(line1[1])
nr = []
b = []
count = 0
line2 = input().split()
for i in line2:
	nr.append(int(i))
	b.append(bool(1))
nr = sorted(nr)
i = 1
while i < n:
	if nr[i] - nr[i - 1] <= k and nr[i] > nr[i - 1]:
		b[i - 1] = bool(0)
	i += 1
i = n - 1
while i > 0:
	while i > 0 and b[i]:
		i -= 1
	j = i
	while j >= 0 and nr[j] == nr[i] and (i > 0):
		b[j] = bool(0)
		j -= 1
	i = j
i = 0
while i < n:
	if b[i]:
		count += 1
	i += 1
print(count)


__file__ = __file__.startswith('/home/a_farazei')

def input_():
	global __file__
	if not __file__:
		return input()
	if not hasattr(__file__, 'readline'):
		__file__ = open('input.txt', 'r')
	return __file__.readline()

class Node:

	def __init__(self, val):
		self.val = val
		self.next = None
		self.prev = None
(n, k) = map(int, input_().split())
arr = sorted(map(int, input_().split()))
res = 0
nodes = [Node(x) for x in arr]
for i in range(n - 1):
	nodes[i].next = nodes[i + 1]
for i in range(1, n):
	nodes[i].prev = nodes[i - 1]
t = nodes[0]
q = t.next
while q and t:
	if t.val < q.val <= t.val + k:
		if t.prev:
			t = t.prev
			t.next = q
			q.prev = t
		else:
			t = q
			t.prev = None
			q = q.next
	else:
		t = q
		q = q.next
while t:
	res += 1
	t = t.prev
print(res)


(n, k) = [int(x) for x in input().split()]
size = sorted([int(x) for x in input().split()])
from itertools import groupby
size = [(k, len(list(l))) for (k, l) in groupby(size)]
res = size[-1][-1]
for i in range(len(size) - 1):
	if size[i + 1][0] > size[i][0] + k:
		res += size[i][1]
print(res)


(n, k) = tuple(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a = sorted(a)
count = len(a)

def canEat(aj, ai):
	return aj < ai and aj >= ai - k
temp = 1
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		temp += 1
	if canEat(a[i], a[i + 1]):
		count -= temp
		temp = 1
	elif a[i] < a[i + 1] and (not canEat(a[i], a[i + 1])):
		temp = 1
print(count)


(n, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a_dict = {}
c = 0
for x in a:
	if x in a_dict.keys():
		a_dict[x] += 1
	else:
		a_dict[x] = 1
a = [(k, v) for (k, v) in a_dict.items()]
a.sort(key=lambda x: x[0])
l = len(a)
for i in range(1, l):
	if a[i][0] - a[i - 1][0] <= k:
		c += a[i - 1][1]
print(n - c)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
m = [0] * (10 ** 6 + 5)
for i in range(n):
	m[l[i]] += 1
count = n
p = -1
for i in range(0, 10 ** 6 + 5):
	if m[i] != 0:
		if p < 0:
			p = i
		else:
			if i <= p + k:
				count -= m[p]
			p = i
print(count)


(n, k) = [int(a) for a in input().split()]
s = sorted([int(a) for a in input().split()], reverse=1)
ans = 1
q = s[0]
for i in range(1, n):
	if not (abs(s[i] - s[i - 1]) <= k and s[i] < q):
		ans += 1
		q = s[i]
print(ans)


x = list(map(int, input().split()))
y = list(map(int, input().split()))
y.sort()
z = []
c = -1
r = x[0]
k = x[0]
for i in range(r - 1):
	if y[i] + x[1] >= y[i + 1] and y[i + 1] > y[i]:
		j = i - 1
		while j >= 0 and y[j] == y[i]:
			j -= 1
			k -= 1
		k -= 1
print(k)


from collections import Counter
I = lambda : map(int, input().split())
(_, K) = I()
C = Counter(I())
prev = 0
for a in sorted(C):
	if a - prev <= K:
		C[prev] = 0
	prev = a
print(sum(C.values()))


(n, k) = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
lst.sort()
f = 0
c = 0
for j in range(n - 1):
	if lst[j + 1] == lst[j]:
		f += 1
	elif lst[j + 1] - lst[j] <= k:
		c += f + 1
		f = 0
	else:
		f = 0
print(n - c)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ls = []
count = 0
for i in range(n):
	if i == 0:
		count += 1
		if i == n - 1:
			ls.append([a[i], count])
	elif a[i] == a[i - 1]:
		count += 1
		if i == n - 1:
			ls.append([a[i], count])
	else:
		ls.append([a[i - 1], count])
		count = 1
		if i == n - 1:
			ls.append([a[i], count])
ans = 0
i = 0
while i < len(ls) - 1:
	if ls[i + 1][0] > ls[i][0] + k:
		ans += ls[i][1]
	i += 1
print(ans + ls[-1][1])


def main():
	(n, K) = input().split(' ')
	n = int(n)
	K = int(K)
	sizes = [int(i) for i in input().split(' ')] + [1000000000.0]
	sizes.sort()
	ans = 0
	upper_bound = 0
	for i in range(n - 1):
		while upper_bound < n and sizes[i] == sizes[upper_bound]:
			upper_bound += 1
		if sizes[upper_bound] <= sizes[i] + K:
			ans += 1
	print(n - ans)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(int(1e+100))
(res, j) = (0, 0)
for i in range(n):
	while j < n + 1 and a[i] == a[j]:
		j += 1
	assert a[i] != a[j]
	if a[j] - a[i] > k:
		res += 1
print(res)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
f = [0] * (10 ** 6 + 1)
for i in a:
	f[i] += 1
b = []
for i in range(10 ** 6 + 1):
	if f[i] > 0:
		b.append(i)
ans = 0
for i in range(len(b) - 1):
	if b[i] < b[i + 1] and b[i] + k >= b[i + 1]:
		ans += f[b[i]]
print(n - ans)