#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<string.h>

using namespace std;
struct AREA {
	long long int x, y, d;
};
struct ANS {
	int X, Y, D, X1, Y1, D1;
};
int N, K;
long long int tmp;
AREA box[101], del;
ANS Box[51];
int main() {
	del.x = 0;
	del.y = 0;
	del.d = 0;
	cin >> N >> K;
	for (int i = 0; i < 2 * N; i++) {
		cin >> box[i].x >> box[i].y >> box[i].d;
		if (i % 2 == 0){
			Box[i / 2].X = box[i].x;
			Box[i / 2].Y = box[i].y;
			Box[i / 2].D = box[i].d;
		}
		else {
			Box[i / 2].X1 = box[i].x;
			Box[i / 2].Y1 = box[i].y;
			Box[i / 2].D1 = box[i].d;
		}
	}
	for (int i = 0; i < 2*N; i++) {
		for (int j = 2*N - 1; j > i; j--) {
			if (box[j - 1].x > box[j].x) {
				tmp = box[j - 1].x;
				box[j - 1].x = box[j].x;
				box[j].x = tmp;
			}
			if (box[j - 1].x == box[j].x&&box[j - 1].x != 1000000000) {
				box[j].x = 1000000000;
				del.x++;
			}
			if (box[j - 1].y > box[j].y) {
				tmp = box[j - 1].y;
				box[j - 1].y = box[j].y;
				box[j].y = tmp;
			}
			if (box[j - 1].y == box[j].y&&box[j - 1].x != 1000000000) {
				box[j].y = 1000000000;
				del.y++;
			}
			if (box[j - 1].d > box[j].d){
				tmp = box[j - 1].d;
				box[j - 1].d = box[j].d;
				box[j].d = tmp;
				}
			if (box[j - 1].d == box[j].d&&box[j - 1].d != 1000000000) {
				box[j].d = 1000000000;
				del.d++;
			}
		}
	}
	int CNT=0;
	long long int ANS=0;
	for (int i = 0; i < 2 * N - del.x - 1; i++) {
		for (int j = 0; j < 2 * N - del.y - 1; j++) {
			for (int k = 0; k < 2 * N - del.d - 1; k++) {
				for (int l = 0; l < N; l++) {
					if (Box[l].X <= box[i].x&&box[i + 1].x <= Box[l].X1&&Box[l].Y <= box[j].y&&box[j + 1].y <= Box[l].Y1&&Box[l].D <= box[k].d&&box[k + 1].d <= Box[l].D1)
						CNT++;
				}
				if (CNT >= K)
					ANS += (box[i + 1].x - box[i].x)*(box[j + 1].y - box[j].y)*(box[k + 1].d - box[k].d);
				CNT = 0;
			}
		}
	}
	cout << ANS << endl;
	return 0;
}
