'use strict'

function main(s) {

  s = s.split('\n');

  const m = Number(s[0].split(' ')[1]);
  const xyz = s.slice(1, -1).map(l => l.split(' ').map(n => Number(n)));

  const sign = [1, -1];

  let ans = 0;

  for (let i = 0; i <= 1; i++) {
    for (let j = 0; j <= 1; j++) {
      for (let k = 0; k <= 1; k++) {

        xyz.sort((a, b) => {
          const formula_a = sign[i] * a[0] + sign[j] * a[1] + sign[k] * a[2];
          const formula_b = sign[i] * b[0] + sign[j] * b[1] + sign[k] * b[2];
          return formula_a - formula_b;
        });

        const eachSum = [0, 0, 0];
        xyz.slice(0, m).forEach(xyz => {
          eachSum[0] += xyz[0];
          eachSum[1] += xyz[1];
          eachSum[2] += xyz[2];
        });

        const allSum = eachSum.reduce((a, b) => Math.abs(a) + Math.abs(b));

        ans = Math.max(ans, allSum);
      }
    }
  }

  console.log(ans);
}

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