def main():
    n, k = map(int, input().split())
    a = [int(input()) for _ in range(n)]
    dp = [0]*(n)
    for i in range(n):
        maxi = 0
        for j in range(i):
            if abs(a[i]-a[j]) <= k:
                if maxi < dp[j]:
                    maxi = dp[j]
        dp[i] = maxi + 1
    print(dp[n-1])
                
        
if __name__ == '__main__':
    main()