// D - Patisserie ABC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,M; cin>>N>>M;
	vector<ll> X(N),Y(N),Z(N), S(N);
	rp(i, 0, N) cin>>X[i]>>Y[i]>>Z[i];
	ll ans = 0;
	rp(bits, 0, 8){
		priority_queue<ll> pq;
		rp(i, 0, N) pq.push(X[i]*(bits&1?1:-1) + Y[i]*(bits&2?1:-1) + Z[i]*(bits&4?1:-1));
		ll s = 0; rp(i, 0, M){ s += pq.top(); pq.pop(); }
		ans = max(ans, s);
	}
	cout<< ans <<endl;
}