#include <stdio.h>
#include <stdlib.h>
int cmp(const void * a, const void * b)
{
return *((long long *) a) - *((long long *) b);
}
int count(const long long * P, const long long A[], const int N)
{
int n = 1;
long long val = *P;
long long * p = P;
while (--p >= A && *p == val)
n++;
p = P;
while (++p < A + N && *p == val)
n++;
return n;
}
int main(void)
{
int N, C;
scanf("%d %d", &N, &C);
long long num[200000];
for (int i = 0; i < N; i++)
scanf("%lld", &num[i]);
qsort(num, N, sizeof(long long), cmp);
int ans = 0;
for (int i = 0; i < N; i++)
{
long long A = num[i] + C;
long long * p = bsearch(&A, num, N, sizeof(long long), cmp);
if (p)
ans += count(p, num, N);
}
printf("%d", ans);
return 0;
}