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

ans = 0

for i in range(1 << N):
    min_a = 100
    min_b = 100
    max_a = 0
    max_b = 0
    cnt = 0
    for j in range(N):
        if i & (1 << j):
            min_a = min(min_a, A[j])
            min_b = min(min_b, B[j])
            max_a = max(max_a, A[j])
            max_b = max(max_b, B[j])
            cnt += 1
    if max_a - min_a <= K and max_b - min_b <= K:
        ans = max(ans, cnt)


print(ans)
