import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto X = new long[](N);
    auto Y = new long[](N);
    auto Z = new long[](N);
    foreach (i; 0 .. N)
        scan(X[i], Y[i], Z[i]);
    auto x = new long[](N);
    auto y = new long[](N);
    auto z = new long[](N);
    long ans = long.min;
    foreach (s; 0 .. 2 ^^ 3)
    {
        x[] = X[];
        y[] = Y[];
        z[] = Z[];
        if ((s & (1 << 0)) != 0)
            x[] *= -1;
        if ((s & (1 << 1)) != 0)
            y[] *= -1;
        if ((s & (1 << 2)) != 0)
            z[] *= -1;
        // writeln(x, X);
        zip(x, y, z).sort!"a[0]+a[1]+a[2]>b[0]+b[1]+b[2]"();
        ans = ans.max(abs(sum(x[0 .. M])) + abs(sum(y[0 .. M])) + abs(sum(z[0 .. M])));
    }
    writeln(ans);
}
