import java.util.*;
import java.util.Arrays;
import java.util.HashSet;
public class Main1{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while(in.hasNext()){
            String[] str=in.nextLine().split(" ");
            int n=Integer.parseInt(str[0]);
            int k=Integer.parseInt(str[1]);
//            List<Integer> list = new ArrayList<>();
            int[] list = new int[n];
            int count=0;
            for(int i=0;i<n;i++){
                list[i] = in.nextInt();
            }
            Arrays.sort(list);
            System.out.println(findnum(list, n, k));
        }
    }
    
    private static int findnum(int[] data, int n, int k){
        int begin = 0;
        int end  =0;
        HashSet<ArrayList<Integer>> chak = new HashSet<ArrayList<Integer>>();
        while(end<n && begin<n){
            while(end <n-1 && data[end] - data[begin] <k){
                end++;
            }
            if(data[end]-data[begin]==k){
                ArrayList<Integer> vtemp = new ArrayList<Integer>();
                vtemp.add(data[begin]);
                vtemp.add(data[end]);
                chak.add(vtemp);
            }
            begin++;
        }
        return chak.size();
    }
}