n, m = io.read("*n", "*n")
t = {}
for i = 1, 8 do t[i] = {} end
for i = 1, n do
  a, b, c = io.read("*n", "*n", "*n")
  for flg = 1, 8 do
    aflg = flg % 2 == 0 and 1 or -1
    bflg = flg % 4 <= 1 and 1 or -1
    cflg = flg <= 4 and 1 or -1
    t[flg][i] = a * aflg + b * bflg + c * cflg
  end
end
for i = 1, 8 do
  table.sort(t[i], function(x, y) return x > y end)
end

summax = 0
for flg = 1, 8 do
  sum = 0
  for i = 1, m do
    sum = sum + t[flg][i]
  end
  if(flg == 1) then summax = sum else summax = math.max(summax, sum) end
end
print(summax)
