(n,d) = map(int, raw_input().rstrip().split(' '))
points = map(int, raw_input().rstrip().split(' '))

pointsInCircle = []
maxcount = 0
for i in range(len(points)):
  count = 0
  for j in range(len(points)):
    if abs(points[i]-points[j]) <= d:
      count += 1
  if count > maxcount:
    maxcount = count
    
print len(points)-maxcount