import std.stdio, std.conv, std.string, std.algorithm;

void main() {
	int N, M;
	int [] t;
	t  = readln().chomp().split().to!(int[]);
	N = t[0]; M = t[1];

	long [][] a;
	foreach(int i; 0..N)
		a ~= readln().chomp().split().to!(long[]);

	long res = 0;
	foreach(int i; 0..(1<<3)) {
		long [] b;
		foreach(int j; 0..N) {
			long c = 0;
			foreach(int k; 0..3) {
				if(i&(1<<k))
					c += a[j][k];
				else
					c -= a[j][k];
			}
			b ~= c;
		}
		b.sort!("a > b");
		long d = 0;
		foreach(int j; 0..M) {
			d += b[j];
		}
		res = max(res,d);
	}
	writefln("%d",res);
}
