import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Cake = Tuple!(long, "x", long, "y", long, "z");

void main() {
    int n, m;
    scan(n, m);

    auto cs = new Cake[](n);

    foreach (i ; 0 .. n) {
        long xi, yi, zi;
        scan(xi, yi, zi);
        cs[i] = Cake(xi, yi, zi);
    }

    long ans;

    foreach (i ; 0 .. 2) {
        foreach (j ; 0 .. 2) {
            foreach (k ; 0 .. 2) {
                cs.sort!((a, b) => (-1)^^i * a.x + (-1)^^j * a.y + (-1)^^k * a.z
                                    > (-1)^^i * b.x + (-1)^^j * b.y + (-1)^^k * b.z);

                long xs, ys, zs;

                foreach (ii ; 0 .. m) {
                    xs += cs[ii].x;
                    ys += cs[ii].y;
                    zs += cs[ii].z;
                }

                ans = max(ans, abs(xs) + abs(ys) + abs(zs));
            }
        }
    }

    writeln(ans);
}







































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
