function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  x = new Array(n);
  y = new Array(n);
  z = new Array(n);
  sum1=new Array(n);
  sum2=new Array(n);
  sum3=new Array(n);
  sum4=new Array(n);
  sum5=new Array(n);
  sum6=new Array(n);
  sum7=new Array(n);
  sum8=new Array(n);
  var ans = 0;
  for(i=0;i<n;i++){
    tmp=input[i+1].split(" ");
    x[i]=parseInt(tmp[0]);
    y[i]=parseInt(tmp[1]);
    z[i]=parseInt(tmp[2]);
    sum1[i]=x[i]+y[i]+z[i];
    sum2[i]=x[i]+y[i]-z[i];
    sum3[i]=x[i]-y[i]+z[i];
    sum4[i]=x[i]-y[i]-z[i];
    sum5[i]=-x[i]+y[i]+z[i];
    sum6[i]=-x[i]+y[i]-z[i];
    sum7[i]=-x[i]-y[i]+z[i];
    sum8[i]=-x[i]-y[i]-z[i];
  }
  sum1.sort(function(a,b){return b-a});
  sum2.sort(function(a,b){return b-a});
  sum3.sort(function(a,b){return b-a});
  sum4.sort(function(a,b){return b-a});
  sum5.sort(function(a,b){return b-a});
  sum6.sort(function(a,b){return b-a});
  sum7.sort(function(a,b){return b-a});
  sum8.sort(function(a,b){return b-a});
  var sum1s=0;
  var sum2s=0;
  var sum3s=0;
  var sum4s=0;
  var sum5s=0;
  var sum6s=0;
  var sum7s=0;
  var sum8s=0;

  for(i=0;i<m;i++){
    sum1s+=sum1[i];
    sum2s+=sum2[i];
    sum3s+=sum3[i];
    sum4s+=sum4[i];
    sum5s+=sum5[i];
    sum6s+=sum6[i];
    sum7s+=sum7[i];
    sum8s+=sum8[i];
  }
  ans=Math.max(sum1s,sum2s,sum3s,sum4s,sum5s,sum6s,sum7s,sum8s);

  


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));