#include <bits/stdc++.h> 

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define rep1(i,n) for(int (i)=1;(i)<=n;(i)++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define vci(v) for(int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vdb;
typedef vector<vector<double>> vvdb;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<pair<int,int>> vpii;
typedef pair<int,int> pii;

const string Alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> Dir={{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> inline T gcd(T a,T b){ if(a%b){ return gcd(b,a%b); }else{ return b; } }
template<typename T> inline T lcm(T a,T b){ return a/gcd(a,b)*b; }

template<typename T> inline T Mpow(T n,T m,T mod){
	long long res=1,pow=n;
	while(m){
		if(m&1) res=(res*pow)%mod;
		pow=(pow*pow)%mod;
		m>>=1;
	}
	return res;
}

pair<int,int> Thre; vector<int> v;

template<typename T> inline bool judge(T n){ return (Thre.first<=v[n]&&Thre.sec>=v[n]); }

template<typename T> inline T BiS(T bottom,T ceiling,bool thretype){
	T upper=ceiling+thretype;
	T lower=bottom-(!thretype);
	while(upper-lower>1){
		T mid=(upper+lower)/2;
		if(judge(mid)) (thretype?lower:upper)=mid;
		else (thretype?upper:lower)=mid;
	}
	return (thretype?lower:upper);
}

template<class T,class U> inline auto LB(T& v,U in){ return lower_bound(v.begin(),v.end(),in); }
template<class T,class U> inline auto UB(T& v,U in){ return upper_bound(v.begin(),v.end(),in); }

int N,M;
vvll List(1001,vll(3));

inline void solve(){
	/*int N; cin>>N;
	int A[10001];
	rep(i,N) cin>>A[i];
	int ans=0;
	rep(i,N){
		int a=A[i]&-A[i];
		while(a){
			a/=2;
			ans++;
		}
		ans--;
	}
	cout<<ans<<endl;*/
	ll ans=0;
	rep(j,8){
		ll a=j>>2;
		ll b=(j-4*a)>>1;
		ll c=j-4*a-2*b;
		vll now(N,0);
		rep(i,N){
			if(a) now[i]+=List[i][0]; else now[i]-=List[i][0];
			if(b) now[i]+=List[i][1]; else now[i]-=List[i][1];
			if(c) now[i]+=List[i][2]; else now[i]-=List[i][2];
		}
		sort(now.begin(),now.end());
		ll tem=0;
		rep(m,M){
			tem+=now.back();
			now.pob();
		}
		ans=max(ans,tem);
	}
	cout<<ans<<endl;
	return;
}

inline void input(){
	cin>>N>>M;
	rep(i,N) rep(j,3) cin>>List[i][j];
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}





Measured memory_bytes: 384