import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
    [n,m] <- map read . words <$> getLine
    xs <- replicateM n $ list2tuple . map read . words <$> getLine
    print $ solve xs m

list2tuple :: [Int] -> (Int,Int,Int)
list2tuple [x1,x2,x3] = (x1,x2,x3)

solve :: [(Int,Int,Int)] -> Int -> Int
solve xs m = maximum $ (map . flip ($)) xs $ map (((abs . sum . take m . sortBy (flip compare)) .) . map) fs
    where fs = [(\(x,y,z) -> x+y+z)
               ,(\(x,y,z) -> x+y-z)
               ,(\(x,y,z) -> x-y+z)
               ,(\(x,y,z) -> x-y-z)
               ,(\(x,y,z) -> -x+y+z)
               ,(\(x,y,z) -> -x+y-z)
               ,(\(x,y,z) -> -x-y+z)
               ,(\(x,y,z) -> -x-y-z)
               ]
