import Control.Monad
import Data.List
main = do
  [n,m] <- map read . words <$> getLine
  xyzs <- replicateM n $ map read . words <$> getLine
  print $ maximum [
    sum $ drop (n-m) $ sort $ map (sum . zipWith (*) ss) xyzs |
    ss <- replicateM 3 [-1,1]]