def pointextractor():
    n,d = map(int,raw_input().split(" "))
    arr = []
    arr = map(int,raw_input().split(" "))
    #print arr
    arr.sort()
    i = 0
    j = n -1
    while(d < (arr[j]-arr[i])):
        if(arr[j-1]-arr[i] > arr[j]-arr[i+1]):
            i = i+1
        else:
            j = j-1
    print n-(j-i+1)

pointextractor()
