function cmp(a, b){
    return (b-a);
}

function main(input) {
    const args = input.split('\n');
    const N_M = args[0].split(' ');
    const N = parseInt(N_M[0]);
    const M = parseInt(N_M[1]);
    var cakes = [];
    for(var i = 1; i <=N; i++){
        var cake = [];
        cake.push(parseInt(args[i].split(' ')[0]));
        cake.push(parseInt(args[i].split(' ')[1]));
        cake.push(parseInt(args[i].split(' ')[2]));
        cakes.push(cake);
    }
    var ans = 0;
    
    for(var b = 0; b < 8; b++){
        var arr = [];
        for(var i = 0; i < N; i++){
            var sum = 0;
            for(var j = 0, k = 1; j < 3; j++, k*=2){
                sum += cakes[i][j] * (b&k?1:-1);
            }
            arr.push(sum);
        }
        arr.sort(cmp);
        var tmp = 0;
        for(var i = 0; i < M; i++)tmp = tmp + arr[i];
        //console.log(arr);
        if(tmp>ans)ans=tmp;
    }
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));