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

class LazySegTree:
    # RMQ and RUQ
    def __init__(self, init_val, seg_ide, lazy_ide, segfunc):
        self.n = len(init_val)
        self.num = 2**(self.n-1).bit_length()

        self.seg_ide = seg_ide
        self.lazy_ide = lazy_ide

        self.segfunc = segfunc

        # seg, lazy: 1-indexed
        self.seg = [seg_ide]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num] = init_val[i]
        for i in range(self.num-1, 0, -1):
            self.seg[i] = self.segfunc(self.seg[2*i], self.seg[2*i+1])

        self.lazy = [lazy_ide]*2*self.num

    def gindex(self, l, r):
        # l, r: 1-indexed
        L = l + self.num
        R = r + self.num
        lm = (L // (L & -L)) >> 1
        rm = (R // (R & -R)) >> 1
        while L < R:
            if R <= rm:
                yield R
            if L <= lm:
                yield L
            L = L >> 1
            R = R >> 1
        while L:
            yield L
            L = L >> 1

    def propagate(self, *ids):
        # ids: 1-indexed
        for i in reversed(ids):
            v = self.lazy[i]
            if v is None:
                continue
            self.lazy[2*i] = self.lazy[2*i+1] = self.seg[2*i] = self.seg[2*i+1] = v
            self.lazy[i] = None

    def update(self, l, r, x):
        # l, r: 0-indexed
        # change x to [l, r)
        *ids, = self.gindex(l, r)
        self.propagate(*ids)
        L = l + self.num
        R = r + self.num
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R] = self.seg[R] = x
            if L & 1:
                self.lazy[L] = self.seg[L] = x
                L += 1
            L = L >> 1
            R = R >> 1
        for i in ids:
            # i: 1-indexed
            self.seg[i] = self.segfunc(self.seg[2*i], self.seg[2*i+1])

    def query(self, l, r):
        # l, r: 0-indexed
        # query for [l, r)
        if r <= l:
            return self.seg_ide

        self.propagate(*self.gindex(l, r))
        L = l + self.num
        R = r + self.num
        res = self.seg_ide
        while L < R:
            if R & 1:
                R -= 1
                res = self.segfunc(res, self.seg[R])
            if L & 1:
                res = self.segfunc(self.seg[L], res)
                L += 1
            L = L >> 1
            R = R >> 1
        return res

    def __str__(self): # for debug
        arr = [self.query(i,i+1) for i in range(self.n)]
        return str(arr)

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():
    n, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(key=lambda x: x)
    #print(A)
    seg = LazySegTree([0]*(10**6+5), 0, 0, max)
    for a in A:
        seg.update(max(a-K,0), a, 0)
        seg.update(a, a+1, 1)
    ans = 0
    for i in range(10**6+1):
        ans += seg.query(i, i+1)
    print(ans)

if __name__ == '__main__':
    main()
