_, d = input().split()
d = int(d)
xs = input().split()
xs = list(map(int, xs))
xs.sort()
a = 0
while True:
  if d >= xs[-1] - xs[0]:
    print(a)
    break
  else:
    try:
      if xs[-1] - xs[-2] >= xs[1] - xs[0]:
        xs.pop(-1)
      else: xs.pop(0)
    except: pass
    a += 1
  
