def FlatSub():
    n, k = map(int, input().split())
    a = [int(input()) for _ in range(n)]
    diff = []
    ans, count = 0, 0

    for i in range(n-1):
        num = a[i+1]-a[i]
        diff.append(num)
        if abs(num) <= k:
            count += 1
        else:
            ans = max(ans, count)
            count = 0 
        
    count = 0
    for i in range(1, n-1):
        if abs(diff[i]) <= k:
            count += 1
        else:
            if abs(diff[i+1]+diff[i]) <= k or abs(diff[i-1]+diff[i]) <= k:
                continue
            else:
                ans = max(count, ans)
                count = 0
            
    print(max(ans, count)+1)
    
if __name__ == '__main__':
    FlatSub()
