#include<bits/stdc++.h>
#include <queue>
#define LL long long
using namespace std;
LL n,m,ans,tt,x[1001],y[1001],z[1001];
int main(){
  scanf("%lld %lld",&n,&m);
  for(LL i=1;i<=n;i++){
  	scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  }
  for(LL i=-1;i<=1;i+=2){
  	 for(LL j=-1;j<=1;j+=2){
  	 	for(LL k=-1;k<=1;k+=2){
  	 	   priority_queue <LL> hh;
			  for(LL l=1;l<=n;l++){
  	 	   	  hh.push(i*x[l]+j*y[l]+k*z[l]);
		   }
		   tt=0;
		   for(LL l=1;l<=m;l++){
		   	  tt+=hh.top();
		   	  hh.pop();
		   }
		   if(tt>ans)
		     ans=tt;
	    }
     }
  }
  printf("%lld",ans);
  return 0;
}