#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int m, n,x,i,k;
vector<int> vec1,vec;
int count=0;
while (cin >> m >>k) {
for(i=0;i<m;i++){
cin>>x;
vec1.push_back(x);
}
sort(vec1.begin(), vec1.end());
vec.push_back(vec1[0]);
for(i=1;i<m;i++){
if(vec1[i]!=vec1[i-1])
vec.push_back(vec1[i]);
}
m=0;
n=1;
while(m<n&&n<vec.size()){
if(vec[n]-vec[m]==k){
count++;
m++;
n++;
}
else if(vec[n]-vec[m]>k){
m++;
}
else{
n++;
}
}
if(vec[n]-vec[n-1]==k)
count++;
cout<<count<<endl;
vec.clear();
vec1.clear();
}
return 0;
}