function main(input) {
  var inputs = input.split("\n");
  var n = Number(inputs[0].split(' ')[0]);
  var m = Number(inputs[0].split(' ')[1]);

  var ppp = [];
  var ppm = [];
  var pmp = [];
  var pmm = [];
  var mpp = [];
  var mmp = [];
  var mpm = [];
  var mmm = [];

  var xArray = [];
  var yArray = [];
  var zArray = [];
  for(var i = 1; i <= n; i++){
    var lines = inputs[i].split(' ');
    xArray[i] = BigInt(lines[0]);
    yArray[i] = BigInt(lines[1]);
    zArray[i] = BigInt(lines[2]);

    ppp.push(xArray[i] + yArray[i] + zArray[i]);
    ppm.push(xArray[i] + yArray[i] - zArray[i]);
    pmp.push(xArray[i] - yArray[i] + zArray[i]);
    pmm.push(xArray[i] - yArray[i] - zArray[i]);
    mpp.push(- xArray[i] + yArray[i] + zArray[i]);
    mmp.push(- xArray[i] - yArray[i] + zArray[i]);
    mpm.push(- xArray[i] + yArray[i] - zArray[i]);
    mmm.push(- xArray[i] - yArray[i] - zArray[i]);
  }

  var rank = [];
  rank.push(BigInt.asUintN(64, ppp.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, ppm.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, pmp.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, pmm.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, mpp.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, mmp.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, mpm.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));
  rank.push(BigInt.asUintN(64, mmm.sort().reverse().slice(0, m).reduce(function(current, next){return current + next;})));

  console.log(String(rank.sort().pop()));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));