import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val param =Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toLong))
    .toArray

  val res = for {
    i <- -1 to 1 by 2
    j <- -1 to 1 by 2
    k <- -1 to 1 by 2
  } yield {
    param.map(e => e(0)*i + e(1)*j + e(2)*k)
      .sorted(Ordering[Long].reverse)
      .take(m)
      .sum
  }

  val ans = res.max
  println(ans)
}