#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, M;
LL x[1000], y[1000], z[1000];
int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++) cin >> x[i] >> y[i] >> z[i];
	LL ans = 0;
	for(int i=-1; i<=1; i+=2){
		for(int j=-1; j<=1; j+=2){
			for(int k=-1; k<=1; k+=2){
				LL tmp[1000];
				for(int l=0; l<N; l++){
					tmp[l] = i*x[l] + j*y[l] + k*z[l];
				}
				sort(tmp, tmp+N, greater<LL>());
				LL sum = 0;
				for(int l=0; l<M; l++){
					sum += tmp[l];
				}
				ans = max(ans, sum);
			}
		}
	}
	cout << ans << endl;
}