fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val XYZ = Array(N) { readLine()!!.split(" ").map(String::toLong) }
    
    val signs =  arrayOf(
        arrayOf(+1, +1, +1),
        arrayOf(+1, +1, -1),
        arrayOf(+1, -1, +1),
        arrayOf(+1, -1, -1),
        arrayOf(-1, +1, +1),
        arrayOf(-1, +1, -1),
        arrayOf(-1, -1, +1),
        arrayOf(-1, -1, -1)
    )
    
    println(signs.map { sign ->
        XYZ.map {
            sign[0] * it[0] + sign[1] * it[1] + sign[2] * it[2]
        }.sortedDescending().slice(0 until M).sum() 
    }.max())
}
