let scanInts _ = stdin.ReadLine().Split() |> Array.toList |> List.map int
let scanIntsML n = [ for i in 1..n -> scanInts 0 ]

let rec transpose = function
    | (_::_)::_ as M -> List.map List.head M :: transpose (List.map List.tail M)
    | _ -> []

let eightval lst = 
  let sgn = [1;-1]
  match lst with
    | [x;y;z] -> [ for i in sgn do for j in sgn do for k in sgn do yield i*x + j*y + k*z ]
    | _ -> failwith "omg"

let [n;m] = scanInts 0

scanIntsML n 
|> List.map eightval
|> transpose
|> List.map (List.toArray >> Array.sort >> Array.rev >> (fun a -> a.[0..m-1]) >> Array.sum)
|> Seq.max
|> printfn "%d"