import java.util.ArrayList

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { s -> s.toInt() }
    val x = Array(N) {0L}
    val y = Array(N) {0L}
    val z = Array(N) {0L}

    for (i in 0 until N) {
        val (a, b, c) = readLine()!!.split(" ").map {s -> s.toLong() }
        x[i] = a
        y[i] = b
        z[i] = c
    }

    var res = (-1e18).toLong()

    for (i in -1 .. 1 step 2) for(j in -1 .. 1 step 2) for(k in -1 .. 1 step 2) {
        val v = ArrayList<Long>()

        for(l in 0 until N) {
            v.add(x[l] * i + y[l] * j + z[l] * k)
        }

        v.sort()
        v.reverse()

        res = Math.max(res, v.subList(0, M).sum())
    }

    println(res)
}