#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct POS{
	int num;
	int coord[3];
	bool begin;
};

long long scan_d(vector<bool> &vec_x,vector<bool> &vec_y,vector<POS> &vec_d,int N,int K)
{
	vector<bool> vec(N);
	fill(vec.begin(),vec.end(),false);
	
	int count=0;
	int begin;
	long long total = 0;
	for(POS &p : vec_d ){
		if( !vec_x[p.num] ) continue;
		if( !vec_y[p.num] ) continue;

		if( p.begin ){
			if(count>=K){
				total += (p.coord[2]-begin);
//				cout << "D:" << begin << "-" << p.coord[2] << endl;
			}
			vec[p.num]=true;
			count++;
			if( count>=K ){
				begin = p.coord[2];
			}
		}else{
			if(count>=K){
				total += (p.coord[2]-begin);
//				cout << "D:" << begin << "-" << p.coord[2] << endl;
			}
			vec[p.num]=false;
			count--;
			if( count>=K ){
				begin = p.coord[2];
			}
		}
	}
	return total;
}

long long scan_y(vector<bool> &vec_x,vector<POS> &vec_y,vector<POS> &vec_d,int N,int K)
{
	vector<bool> vec(N);
	fill(vec.begin(),vec.end(),false);
	
	int count=0;
	int begin;
	long long size;
	long long total = 0;
	for(POS &p : vec_y ){
		if( !vec_x[p.num] ) continue;

		if( p.begin ){
			if(count>=K){
				total += (p.coord[1]-begin) * size;
//				cout << "Y:" << begin << "-" << p.coord[1] << endl;
			}
			vec[p.num]=true;
			count++;
			if( count>=K ){
				begin = p.coord[1];
				size = scan_d(vec_x, vec,vec_d,N,K);
			}
		}else{
			if(count>=K){
				total += (p.coord[1]-begin) * size;
//				cout << "Y:" << begin << "-" << p.coord[1] << endl;
			}
			vec[p.num]=false;
			count--;
			if( count>=K ){
				begin = p.coord[1];
				size = scan_d(vec_x, vec,vec_d,N,K);
			}
		}
	}
	return total;
}

long long scan_x(vector<POS> &vec_x,vector<POS> &vec_y,vector<POS> &vec_d,int N,int K)
{
	vector<bool> vec(N);
	fill(vec.begin(),vec.end(),false);
	
	int count=0;
	int begin;
	long long size;
	long long total = 0;
	for(POS &p : vec_x ){
		if( p.begin ){
			if(count>=K){
				total += (p.coord[0]-begin) * size;
//				cout << "X:" << begin << "-" << p.coord[0] << endl;
			}
			vec[p.num]=true;
			count++;
			if( count>=K ){
				begin = p.coord[0];
				size = scan_y(vec, vec_y,vec_d,N,K);
			}
		}else{
			if(count>=K){
				total += (p.coord[0]-begin) * size;
//				cout << "X:" << begin << "-" << p.coord[0] << endl;
			}
			vec[p.num]=false;
			count--;
			if( count>=K ){
				begin = p.coord[0];
				size = scan_y(vec, vec_y,vec_d,N,K);
			}
		}
	}
	return total;
}

int main() {
	int N,K;
	cin >> N >> K;
	
	vector<POS> vec;

	for(int i=0;i<N;i++){
		POS p0,p1;
		cin >> p0.coord[0] >> p0.coord[1] >> p0.coord[2];
		cin >> p1.coord[0] >> p1.coord[1] >> p1.coord[2];
		p0.num=i;
		p0.begin=true;
		p1.num=i;
		p1.begin=false;
		vec.push_back(p0);
		vec.push_back(p1);
	}

	vector<POS> vec_x(vec);
	vector<POS> vec_y(vec);
	vector<POS> vec_d(vec);

	sort(vec_x.begin(),vec_x.end(),[](const POS &p0,const POS &p1){ return p0.coord[0]<p1.coord[0];});
	sort(vec_y.begin(),vec_y.end(),[](const POS &p0,const POS &p1){ return p0.coord[1]<p1.coord[1];});
	sort(vec_d.begin(),vec_d.end(),[](const POS &p0,const POS &p1){ return p0.coord[2]<p1.coord[2];});

	// for( POS p : vec_x ){
	// 	cout << p.coord[0] << " ";
	// }
	// cout << endl;

	long long ans = scan_x(vec_x,vec_y,vec_d,N,K);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1228