fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val X = LongArray(N); val Y = LongArray(N); val Z = LongArray(N)
    repeat(N) { n ->
        val (x, y, z) = listOfLong()
        X[n] = x; Y[n] = y; Z[n] = z
    }
    var ans = 0L
    for (b in 0 until 8) {
        val A = LongArray(N)
        for (n in 0 until N) {
            A[n] += (if ((b and 1) == 0) X[n] else -X[n])
            A[n] += (if ((b and 2) == 0) Y[n] else -Y[n])
            A[n] += (if ((b and 4) == 0) Z[n] else -Z[n])
        }
        A.sortDescending()
        var w = A.slice(0 until M).sum()
        if (ans < w) ans = w
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
