"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let A = new Array(N), X = new Array(N), Y = new Array(N), Z = new Array(N);
	for (let n = 0; n < N; n++) {
		X[n] = cin.getInt(), Y[n] = cin.getInt(), Z[n] = cin.getInt();
	}
    let ans = 0;
    for (let n = 0; n < 8; n++) {
        let B = ('00' + n.toString(2)).substr(-3);
        for (let m = 0; m < N; m++) {
            A[m]  = B[0] == 0 ? X[m]: -X[m];
            A[m] += B[1] == 0 ? Y[m]: -Y[m];
            A[m] += B[2] == 0 ? Z[m]: -Z[m];
        }
        let w = 0;
        A.sort((a, b) => b - a);
        for (let m = 0; m < M; m++) {
            w += A[m];
        }
        if (ans < w) ans = w;
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));