import Data.Array.IO
import Data.List
import Control.Monad


main = do
  (n:m:_) <- getLine >>= return . map read . words :: IO [Int]
  dat <- getContents >>= return . map ((\(x:y:z:_) -> (x,y,z)) . map read . words) . lines :: IO [(Integer,Integer,Integer)]

  print $ maximum $ map (solve m dat) [(1,1,1), (-1,1,1), (1,-1,1), (1,1,-1), (-1,-1,1), (-1,1,-1), (1,-1,-1), (-1,-1,-1)]
  
  where
    solve m xs (a,b,c) = sum . take m . reverse . sort $ map (\(x,y,z) -> a*x+b*y+c*z) xs
  
