#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
//堀江伸一 会津大学オンラインジャッジ問3422 Pyramid Planet
struct E{
	int x,y,z;
};

vector<E> vs;
int memo[103][103][103];

int main() {
	int n,k;
	int ans=0;
	memset(memo,0,sizeof(memo));
	cin>>n>>k;
	
	for(int i=0;i<n;i++){
		int x,y,z,h;
		E e1;
		cin>>x>>y>>z>>h;
		e1.x=x;
		e1.y=y;
		e1.z=z;
		vs.push_back(e1);
		for(int j=1;j<h;j++){
			memo[z+j][y-j][x-j]++;
			memo[z+j][y+j+1][x-j]--;
			memo[z+j][y-j][x+j+1]--;
			memo[z+j][y+j+1][x+j+1]++;
		}
	}

	
	for(int z=0;z<100;z++){
		for(int x=0;x<100;x++){
			int s1=0;
			for(int y=0;y<100;y++){
				s1+=memo[z][y][x];
				memo[z][y][x]=s1;
			}
		}
	}

	for(int z=0;z<100;z++){
		for(int y=0;y<100;y++){
			int s1=0;
			for(int x=0;x<100;x++){
				s1+=memo[z][y][x];
				memo[z][y][x]=s1;
			}
		}
	}
	for(int i=0;i<vs.size();i++){
		E e1=vs[i];
		memo[e1.z][e1.y][e1.x]++;
	}
	//for(int z=0;z<4;z++){
	//	for(int y=0;y<7;y++){
	//		for(int x=0;x<7;x++){
	//			if(k<=memo[z][y][x])ans++;
	//			cout<<memo[z][y][x]<<" ";
	//		}
	//		cout<<endl;
	//	}
	//	cout<<endl;
	//}
	//cout<<endl;
	
	for(int z=0;z<100;z++){
		for(int y=0;y<100;y++){
			for(int x=0;x<100;x++){
				if(k<=memo[z][y][x])ans++;
			}

		}

	}
	cout<<ans<<endl;
	return 0;
}