#input

n, k = map(int,input().split())
a = [int(input()) for i in range(n)]

def input_2(n,k):
    n, k = map(int,input().split())
    a = [randint(1, k) for i in range(n)]
    return n,k,a

def connect(i,d,p,q):
    if i+d >= n:
        if p > q:
            q = p
        #print("bbbb {} {}".format(p,q))
        return q

    if max(a[i] - a[i+d], a[i+d] - a[i]) <= k:
        #print("aaaa {} {}".format(p+1,q))
        q = connect(i+d,1,p+1,q)
    else:
        #print("aaaa {} {}".format(p,q))
        q = connect(i,d+1,p,q)

    return q

def main():
    #n,m,brg = input_1()
    #n,m,brg = input_2(300000,300000)

    ans = 0

    i = 0
    while i < (n - ans):
        q = connect(i,1,1,1)
        if q > ans:
            ans = q
        i += 1

    print(ans)


if __name__ == '__main__':
    main()