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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;

	cin >> N;
	cin >> M;

	vector<SINT64> ADATA(N);
	vector<SINT64> BDATA(N);
	vector<SINT64> CDATA(N);

	SINT64 A,B,C;
	SINT64 ANS = 0;

	vector<pair<SINT64,SINT64>> ANSDATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> ADATA[i];
		cin >> BDATA[i];
		cin >> CDATA[i];
	}

	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i] + BDATA[i] + CDATA[i];
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));


	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i]*(-1) + BDATA[i] + CDATA[i];
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));


	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i] + BDATA[i]*(-1) + CDATA[i];
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));


	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i] + BDATA[i] + CDATA[i]*(-1);
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));

	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i]*(-1) + BDATA[i] + CDATA[i]*(-1);
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));

	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i]*(-1) + BDATA[i]*(-1) + CDATA[i];
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));

	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i] + BDATA[i]*(-1) + CDATA[i]*(-1);
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));

	for (SINT32 i = 0; i < N; i++) {
		ANSDATA[i].first = ADATA[i]*(-1) + BDATA[i]*(-1) + CDATA[i]*(-1);
		ANSDATA[i].second = i;
	}
	sort(ANSDATA.begin(),ANSDATA.end(),std::greater<pair<SINT64,SINT64>>());
	A = 0; B = 0; C = 0;
	for (SINT32 i = 0; i < M; i++) {
		A += ADATA[ANSDATA[i].second];
		B += BDATA[ANSDATA[i].second];
		C += CDATA[ANSDATA[i].second];
	}
	ANS = MAX(ANS, ABS(A)+ABS(B)+ABS(C));


	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

Measured memory_bytes: 256