"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const nm = input[0].split(' ');
    const n = parseInt(nm[0], 10);
    const m = parseInt(nm[1], 10);
    const xyz = readXYZ(input, n);
    
    const COEF = [
        {x: 1, y: 1, z: 1},
        {x: 1, y: 1, z: -1},
        {x: 1, y: -1, z: 1},
        {x: 1, y: -1, z: -1},
        {x: -1, y: 1, z: 1},
        {x: -1, y: 1, z: -1},
        {x: -1, y: -1, z: 1},
        {x: -1, y: -1, z: -1},
    ];
   
    let ans = 0;
    for (let i = 0; i < COEF.length; i++) {
        ans = Math.max(ans, calcMax(xyz, COEF[i], m));
    }

    console.log(ans);

    return 0;
}

function readXYZ(input, n) {

    let xyz = new Array(n);

    for (let i = 0; i < n; i++) {
        const xyzstr = input[1 + i].split(' ');
        xyz[i] = {
            x: parseInt(xyzstr[0], 10),
            y: parseInt(xyzstr[1], 10),
            z: parseInt(xyzstr[2], 10),
        };
    }

    return xyz;
}

function calcMax(xyz, coef, m) {

    let xyzwork = xyz.concat();

    xyzwork.sort(function(a, b) {
        const aval = coef.x * a.x + coef.y * a.y + coef.z * a.z;
        const bval = coef.x * b.x + coef.y * b.y + coef.z * b.z;
        if (aval > bval) {
            return -1;
        } else if (aval < bval) {
            return 1;
        } else {
            return 0;
        }
    });

    let ret = 0;
    for (let i = 0; i < m; i++) {
        ret += coef.x * xyzwork[i].x + coef.y * xyzwork[i].y + coef.z * xyzwork[i].z;
    }

    return ret;
}