# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

struct star {
	int x, y, b;

	bool operator <(const star &s)const {
		return b < s.b;
	}
};

bool calc(const star &a,const star &b) {
	return a.b < b.b;
}


int n, d;
vector<star> stars;

struct SegmentTreeMax {
private:
	int n;
	vector<LL> node;
public:
	SegmentTreeMax(vector<LL> v) {
		int sz = v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1,0);
		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = max(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = max(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最大値を求める
	LL getmax(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return node[k];

		LL vl = getmax(a, b, 2 * k + 1, l, (l + r) / 2);
		LL vr = getmax(a, b, 2 * k + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
};

struct SegmentTreeMin {
private:
	int n;
	vector<LL> node;
public:
	SegmentTreeMin(vector<LL> v) {
		int sz = v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1, HINF<LL>());
		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最小値を求める
	LL getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return HINF<LL>();
		if (a <= l && r <= b) return node[k];

		LL vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		LL vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	void get() {
		REP(i, node.size()) {
			cout << node[i] << " ";
		}
		cout << endl;
	}
};


int main() {
	cin >> n >> d;
	REP(i, n) {
		star s;
		cin >> s.x >> s.y >> s.b;
		stars.emplace_back(s);
	}
	sort(ALL(stars));
	vector<LL> xx, yy, bb;
	REP(i, n) {
		xx.emplace_back(stars[i].x);
		yy.emplace_back(stars[i].y);
		bb.emplace_back(stars[i].b);
	}
	SegmentTreeMax xmax(xx), ymax(yy);
	SegmentTreeMin xmin(xx), ymin(yy);
	
	LL ans = 0LL;
	REP(i, n) {
		int l = i;
		int r = upper_bound(ALL(bb), bb[i] + d) - 1 - bb.begin();
		//cout << l << " " << r << " " << xmax.getmax(l, r + 1) <<" "<< xmin.getmin(l, r + 1)<<" "<<ymax.getmax(l, r + 1)<< " "<< ymin.getmin(l, r + 1) << endl;
		ans = max(ans, (xmax.getmax(l, r + 1) - xmin.getmin(l, r + 1))*(ymax.getmax(l, r + 1) - ymin.getmin(l, r + 1)));
	}
	//system("pause");
	cout << ans << endl;
	
}


Measured memory_bytes: 28988