function main(input) {
    var lines = input.split('\n');
    var line1 = lines[0].split(' ');
    var N = parseInt(line1[0]);
    var M = parseInt(line1[1]);
 
    var cakes = [];
    for (var i = 1; i < lines.length; i++) {
      var line = lines[i].split(' ');
      var cake = [];
      cake.push(parseInt(line[0]));
      cake.push(parseInt(line[1]));
      cake.push(parseInt(line[2]));
      cakes.push(cake)
    }
 
    var answer = 0;
    var strategies = [
      [-1,-1,-1],
      [-1,-1, 1],
      [-1, 1,-1],
      [-1, 1, 1],
      [ 1,-1,-1],
      [ 1,-1, 1],
      [ 1, 1,-1],
      [ 1, 1, 1]
    ];
    
    strategies.forEach(function(strategy){
      var sum = 0;
 
      var cakePoints = [];
      cakes.forEach(function(cake, i){
        var cakePoint = 0;
        cakePoint += strategy[0] * cake[0];
        cakePoint += strategy[1] * cake[1];
        cakePoint += strategy[2] * cake[2];
        cakePoints.push(cakePoint);
      });
 
      cakePoints.sort(function(a,b){return b - a;});
      for (var i = 0; i < M; i++) {
        sum += cakePoints[i];
      }
 
      answer = answer >= sum ? answer : sum;
    });
 
    console.log(answer);
  }
main(require('fs').readFileSync('/dev/stdin', 'utf8'));