var line = readline().split(' ');
	var n = Number(line[0]);
	var d = Number(line[1]);
	var numbers = readline().split(' ');
	numbers.sort(function(a, b) {
		return a-b;
	});

	var i=0;
	var j=n-1;
	var count=0;
	var ready=false;

	while(i<j) {
		if (numbers[j] - numbers[i] <= d) {
			break;
		}
		if (numbers[j] - numbers[i+1] <= d 
		    || numbers[j-1] - numbers[i] <= d) {
			count++;
			break;
		}
		count+=2;
		i++;
		j--;
	}

	print(count);