using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static int[] op;
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            op = new int[3];
            var p = cin.SplitRead();
            int N = p[0];
            int M = p[1];
            List<Tuple<long, long, long>> cake = new List<Tuple<long, long, long>>();
            for(var i = 0; i < N; i++)
            {
                var input = cin.SplitReadL();
                cake.Add(new Tuple<long, long, long>(input[0], input[1], input[2]));
            }


            long ans = 0;
            for(var bit = 0; bit < (1 << 3); bit++)
            {
                for(var b = 0; b < 3; b++)
                {
                    op[b] = (bit & (1 << b)) != 0 ? 1 : -1;
                }

                cake.Sort(Comp);


                long x = 0;
                long y = 0;
                long z = 0;
                for(var i = 0; i < M; i++)
                {
                    x += cake[i].Item1;
                    y += cake[i].Item2;
                    z += cake[i].Item3;
                }

                ans = Max(ans, Abs(x) + Abs(y) + Abs(z));
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        static int Comp(Tuple<long, long, long> t1, Tuple<long, long, long> t2)
        {
            long t = t1.Item1 * op[0] + t1.Item2 * op[1] + t1.Item3 * op[2];
            long f = t2.Item1 * op[0] + t2.Item2 * op[1] + t2.Item3 * op[2];
            return t > f ? 1 : -1;
        }
        
    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

    public class PrimeList
    {
        private bool[] isprime;
        private List<int> primelist;

        public PrimeList(int n)
        {
            if (n < 2) { return; }
            primelist = new List<int>();
            isprime = new bool[n + 1];
            for (var i = 0; i <= n; i++)
            {
                isprime[i] = i != 0 && i != 1;
            }

            for (var i = 2; i <= n; i++)
            {
                if (!isprime[i]) { continue; }
                primelist.Add(i);

                int c = i;
                while (c + i <= n)
                {
                    c += i;
                    isprime[c] = false;
                }
            }
        }

        public bool IsPrime(int n)
        {
            return isprime[n];
        }

        public List<int> GetPrimeList()
        {
            return primelist;
        }

    }
}


Measured memory_bytes: 11456