fun main(args: Array<String>) {
  val (N, M) = readLine()!!.split(" ").map{it.toInt()}
  val vv = Array(8) {mutableListOf<Long>()}
  val tf = listOf(false, true)
  for (i in 1..N) {
    val (x, y, z) = readLine()!!.split(" ").map{it.toLong()}
    for (i in 0..1) {
      for (j in 0..1) {
        for (k in 0..1) {
          var v = 0L
          if (i==0) v += x else v -= x
          if (j==0) v += y else v -= y
          if (k==0) v += z else v -= z
          vv[i + j*2 + k*4].add(v)
        }
      }
    }
  }
  println(vv.map{it.sortedDescending().take(M).sum()}.max())
}