#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-09-26 22:28:46 +0900
# LastModified: 2020-09-26 22:41:30 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from copy import deepcopy


def main():
    N, K = map(int, input().split())
    A = []
    for _ in range(N):
        A.append(int(input()))
    ans = 0
    for i in range(N):
        cnt = 0
        unko = [A[i]]
        j = 1
        while j < len(A):
            if abs(unko[-1]-A[j]) <= K:
                unko.append(A[j])
                cnt += 1
            j += 1
        if cnt > ans:
            ans = cnt
    print(ans)



if __name__ == "__main__":
    main()
