function main(input){
  var int = parseInt;
  var lines = input.split("\n");
  var typeCount = parseInt(lines[0].split(" ")[0]);
  var eatCount = parseInt(lines[0].split(" ")[1]);
  var numLines = lines.slice(1);
  var answer=0;
  
  for (var i=0;i<numLines.length;i++){
    numLines[i] = arrayParseInt(numLines[i].split(" "));
  }
  for(var i=0;i<2;i++){
    for(var j=0;j<2;j++){
      for(var k=0;k<2;k++){
        var cake = Array(typeCount).fill(0);
        for(var s =0; s<typeCount;s++){
          var sum = 0;
          var x,y,z;
          x = i===0 ? numLines[s][0] : numLines[s][0] *(-1);
          y = j===0 ? numLines[s][1] : numLines[s][1] *(-1);
          z = k===0 ? numLines[s][2] : numLines[s][2] *(-1);
          cake[s] = x+y+z;
        }
        cake.sort((a,b) =>b-a);
        var result = 0;
        for( var p =0;p<eatCount;p++){
          result += cake[p];
          
        }
        answer = Math.max(answer,result);
      }
    }
  }
  
  console.log(answer);
}

function arrayParseInt(array){
  return array.map(Number);
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));