2 1
1 1
 4 1
2 2 1 1
 10 1
2 6 3 4 2 4 4 3 2 1
 2 1
999152 999153
 8 1000000
1 1 5 1000000 1000000 2 2 2
 9 2
1 6 1 5 5 8 6 8 7
 15 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 4
8
 10 1
6 3 1 3 6 4 1 3 6 4
 10 1
1 2 3 5 6 8 10 11 9 4
 7 2
1 5 5 8 9 8 8
 2 1000000
1 1000000
 8 2
3 13 9 8 3 13 9 14
 1 1
1
 2 1
1 2

2
 2
 4
 1
 2
 4
 15
 1
 7
 2
 4
 1
 5
 1
 1

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;


import java.util.StringTokenizer;


 public class Test
 {
    
    static PrintWriter pw = new PrintWriter(System.out);
    static class Pair
    {
        int index;
        int size;
        
        Pair(int a , int b)
        {
            index = a;
            size = b;
        }
    }
    
    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int k = Reader.nextInt();
        ArrayList<Integer> list1 = new ArrayList();
        ArrayList<Pair> list2 = new ArrayList();
        HashSet<Integer> set = new HashSet();
        int res = 0;
        
        for(int i = 0 ; i<n ; i++)
            list1.add(Reader.nextInt());
        
        Collections.sort(list1);
        
        for(int i = 0 ; i<n ; i++)
        {
            int x = list1.get(i);
            if(!set.contains(x))
            {
                list2.add(new Pair(i , x));
                set.add(x);
            }
        }
        
        for(int i = 0 ; i<list2.size() ; i++)
        {
            Pair p = list2.get(i);
            int z = p.size - k;
            
            if(z<0)
                continue;
            
            int bs = 0;
            
            //binary search z
            int L = 0;
            int R = n-1;
            
            while(L<=R)
            {
                int mid = (L+R)/2;
                if(z<=list1.get(mid))
                {
                    R = mid-1;
                }
                else
                {
                    L = mid + 1;
                }
 
            }
            bs = L;
            if(bs<0 || bs > p.index)
                continue;
            res += p.index - bs;
        }
        
        pw.print(n - res);
        pw.close();
    }
        
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}