n,d = map(int,input().split())
ls = list(map(int,input().split()))
lens = len(ls)
ans = 0x7fffffff
for left in range(0,lens):
    for right in range(0,lens):
        if ls[right] - ls[left] <= d:
            ans = min(lens-1 - right + left,ans)
print(ans)
 	 	  				 		   	 	    		 	  		