import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val xyz = Array.fill(N)((sc.nextLong, sc.nextLong, sc.nextLong))

    Array(
      (1, 1, 1), (1, 1, -1), (1, -1, 1), (1, -1, -1),
      (-1, 1, 1), (-1, 1, -1), (-1, -1, 1), (-1, -1, -1)
    ).map { case (dx, dy, dz) =>
        xyz.map { case (x, y, z) =>
          x * dx + y * dy + z * dz
        }.sorted.reverse.take(M).sum
    }.max.toString
  }
}
