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

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