
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class A {
      
   
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = sc.nextInt();
        int k=0;
        if(n==1)
        System.out.println("1");
        else{
        int c[]=new int[n];
        for(int i=0;i<n;i++){
            c[i]=sc.nextInt();
            }
            Arrays.sort(c);
            int i=0;
           while(c[n-1-i]-c[0]!=b){
                 k++;
                 i++;
           }
        
         System.out.println(k); 
        }
         }}