object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val sum = Array.ofDim[Long](n, 3)

	for(i<-0 until n){
		sum(i) = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	}

	var ans = 0L

	for(x <- 0x0 to 0x7){
		var a = new Array[Long](n)

		val a1 = if((0x4 & x)>>2 == 0x1) 1 else -1
		val a2 = if((0x2 & x)>>1 == 0x1) 1 else -1
		val a3 = if((0x1 & x)>>0 == 0x1) 1 else -1

		for(i<-0 until n){
			a(i) = a1*sum(i)(0) + a2*sum(i)(1) + a3*sum(i)(2)
		}

		a = a.sorted.drop(n-m)

		ans = math.max(ans, a.sum)
	}

	println(ans)

}