#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[50100];
struct node{
int x, y;
}a[50100];
bool cmp(node n, node m)
{
return n.x < m.x;
}
int main()
{
int n, k, tot=0;
ll ans = 0;
scanf("%d%d",&n,&k);
for(int i = 1; i <= n; i++) {
scanf("%d%d",&a[i].x,&a[i].y);
}
sort(a+1, a+n+1, cmp);
for(int i = 2; i <= n; i++) {
for(int j = i-1; j >= 1; j--) {
int tmp = a[i].x - a[j].x;
if(tmp >= k) break;
if(abs(a[i].x - a[j].x) < k && abs(a[i].y - a[j].y) < k)
{
tot++;
vis[i] = 1; vis[j] = 1;
ans += (k-abs(a[i].x - a[j].x))*(k-abs(a[i].y - a[j].y));
if(tot == 2) {
printf("-1\n");
return 0;
}
}
}
}
printf("%lld\n",ans);
}