import scala.math.abs

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val xyzs = List.fill(n, 3)(sc.nextLong)

    println(
      (0 until n)
      .toSet
      .subsets
      .filter(_.size == m)
      .map(_.foldLeft(List[Long](0, 0, 0))((stu: List[Long], i: Int) => {
        val List(x, y, z) = xyzs(i)
        val List(s, t, u) = stu
        List(x + s, y + t, z + u)
      }).map(abs).sum)
      .max
    )
  }
}
