def minrem(l, s, e, d):
    minrem = e
    for i in xrange(s, e+1):
      for j in xrange(e, s-1, -1):
        if l[j] - l[i] <= d:
          minrem = min(minrem, e-j+i-s)
          break
    return minrem

n, d = raw_input().split()
d = int(d)
l = raw_input().split()
l = [int(i) for i in l]
l = sorted(l)
print minrem(l, 0, int(n)-1, d)
