function Main(input) {
  var _arr = input[0].split(" "), n = parseInt(_arr[0]), m = parseInt(_arr[1]);
  var x = [], y = [], z = [];
  for (var i=0; i<n; i++) {
    var _arr = input[i+1].split(" ");
    x[i] = parseInt(_arr[0]);
    y[i] = parseInt(_arr[1]);
    z[i] = parseInt(_arr[2]);
  }
  var ans = 0;

  var muls = [1, -1];
  for(var mi=0; mi<2; mi++){
    for(var mj=0; mj<2; mj++){
      for(var mk=0; mk<2; mk++){
        var tmp_arr = [];
        for (var i=0; i<n; i++){
          tmp_arr.push(x[i]*muls[mi] + y[i]*muls[mj] + z[i]*muls[mk]);
        }
        tmp_arr.sort(function (a, b) {
          return a - b;
        });
        var sums = 0;
        for (var i=0; i<m; i++) sums += tmp_arr[n-i-1];
        ans = Math.max(ans, sums);
      }
    }
  }

  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
