N, K = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(N)))

ans = 0
for min_a in range(101):
    for min_b in range(101):
        cnt = 0
        for i in range(N):
            if min_a <= A[i] <= min_a + K and min_b <= B[i] <= min_b + K:
                cnt += 1
        ans = max(ans, cnt)

print(ans)
