n, d = map(int, raw_input().split())
x = map(int, raw_input().split())
ans = n
for i in xrange(101):
    mn, mx = i, i + d
    cnt = 0
    for a in x:
        if a < mn or a > mx:
            cnt += 1
    ans = min(ans, cnt)
print ans
