#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

typedef pair<pair<pii, int>, pair<pii, int>> Block;

signed main() {
	int n, k;
	scanf("%d %d", &n, &k);

	vector<Block> rg(n);
	vector<int> ax(2 * n), ay(2 * n), az(2 * n);
	auto fair = [](Block& block) {
		if (block.first.first.first > block.second.first.first) {
			swap(block.first.first.first, block.second.first.first);
		}
		if (block.first.first.second > block.second.first.second) {
			swap(block.first.first.second, block.second.first.second);
		}
		if (block.first.second > block.second.second) {
			swap(block.first.second, block.second.second);
		}
	};
	REP(i, n) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		rg[i].first = { {x,y},z };
		ax[i * 2] = x;
		ay[i * 2] = y;
		az[i * 2] = z;
		scanf("%d %d %d", &x, &y, &z);
		rg[i].second = { {x,y}, z };
		fair(rg[i]);
		ax[i * 2 + 1] = x;
		ay[i * 2 + 1] = y;
		az[i * 2 + 1] = z;
	}
	sort(ALL(ax));
	sort(ALL(ay));
	sort(ALL(az));
	ax.erase(unique(ALL(ax)),ax.end());
	ay.erase(unique(ALL(ay)), ay.end());
	az.erase(unique(ALL(az)), az.end());
	auto incl = [](int k, int n, Block b1, Block b2) {
		bool f = 1;
		if (b1.first.first.first > b2.first.first.first)
			f = 0;
		if (b1.first.first.second > b2.first.first.second)
			f = 0;
		if (b1.first.second > b2.first.second)
			f = 0;
		if (b1.second.first.first < b2.second.first.first)
			f = 0;
		if (b1.second.first.second < b2.second.first.second)
			f = 0;
		if (b1.second.second < b2.second.second)
			f = 0;
		return f;
	};

	ll res = 0;
	REP(i1, ax.size() - 1) {
		REP(i2, ay.size() - 1) {
			REP(i3, az.size() - 1) {
				Block nb = { {{ax[i1],ay[i2]},az[i3]},{ { ax[i1 + 1],ay[i2 + 1] },az[i3 + 1] } };
				fair(nb);
				int cou = 0;
				REP(i4, n) {
					cou += incl(k, n, rg[i4], nb);
				}
				if(cou >= k)
					res += (ll)(nb.second.first.first - nb.first.first.first) * (nb.second.first.second - nb.first.first.second) * (nb.second.second - nb.first.second);
			}
		}
	}
	printf("%lld\n", res);
	return 0;
}