var lines = [];

var N, M, ans = 0, xyz = []
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', (x) => {
    lines.push(x);
});

rl.on('close', () => {

    N = Number(lines[0].split(" ")[0]);
    M = Number(lines[0].split(" ")[1]);

    lines.shift();

    xyz = lines.map(value => value.split(" ").map(value => Number(value)));

    dfs(0, []);
    console.log(ans);
});

function dfs(n, comb) {
    if (n === 3) { calc(comb); }
    else {
        for (var i = 0; i < 2; i++) {
            comb[n] = i;
            dfs(n + 1, comb);
        }
    }
    return (0);
}

function calc(comb) {

    var result = 0;
    var cake = Array(N).fill(0);

    for (var i = 0; i < N; i++) {
        cake[i] = (comb[0] === 0 ? xyz[i][0] : xyz[i][0] * (-1)) + (comb[1] === 0 ? xyz[i][1] : xyz[i][1] * (-1)) + (comb[2] === 0 ? xyz[i][2] : xyz[i][2] * (-1));
    }
    cake.sort((a, b) => b - a)

    for (var i = 0; i < M; i++) { result += cake[i] }

    ans = Math.max(ans, result);
    return (0)
}