#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;
#define lson 2*i
#define rson 2*i+1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 1000005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define lowbit(x) (x&-x)
int main(){
int m,k;
cin>>m>>k;
int sum=0;
char s[100000010];
int d;
for(int i=0;i<m;i++){
scanf("%d",&d);
s[d]='1';
}
for(int i=0;i<=100000000;i++){
if(s[i]=='1'&& s[i+k]=='1')
sum++;
}
cout<<sum<<endl;
}
//5 2
//1 5 3 4 2