import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int m, long[][] xxs) {

    long ans = 0;
    for (int i = 0; i < 8; i++) {
        long[] xs;
        for (int j = 0; j < xxs.length; j++) {
            long sum = 0;
            for (int k = 0; k < 3; k++) {
                sum += ((i >> k) & 1) == 0 ? xxs[j][k] : -xxs[j][k];
            }
            xs ~= sum;
        }

        xs.sort!"a > b";
        ans = max(ans, xs.take(m).sum);
    }
    return ans;
}

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    long[][] xxs;
    for (int i = 0; i < n; i++) {
        xxs ~= reads!long;
    }

    auto ans = calc(m, xxs);
    writeln(ans);
}