local n, m = io.read("*n", "*n")
local t = {}
for i = 1, 8 do
  t[i] = {}
end
for i = 1, n do
  local a, b, c = io.read("*n", "*n", "*n")
  t[1][i] = a + b + c
  t[2][i] = a + b - c
  t[3][i] = a - b + c
  t[4][i] = a - b - c
  t[5][i] = -a + b + c
  t[6][i] = -a + b - c
  t[7][i] = -a - b + c
  t[8][i] = -a - b - c
end
local ret = 0
for i = 1, 8 do
  local tbl = t[i]
  table.sort(tbl, function(x, y) return x > y end)
  local z = 0
  for j = 1, m do
    z = z + tbl[j]
  end
  if i == 1 or ret < z then
    ret = z
  end
end
print(ret)