using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveD(args);
        }


        static void SolveA(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int a = int.Parse(szArr[0]);
            int b = int.Parse(szArr[1]);

            int dif = a - b;
            if (a >= 9 || b >= 9)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }

        static void SolveB(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int d = int.Parse(szArr[0]);
            int n = int.Parse(szArr[1]);

            int answer = 0;
            if( d == 0)
            {
                if (n == 100)
                {
                    answer = 101;
                    
                }
                else
                {
                    answer = n;
                }
            }else if( d == 1)
            {
                if (n == 100)
                {
                    answer = 100 * 101;
                }
                else
                {
                    answer = 100 * n;
                }
            }else // d == 2
            {
                if (n == 100)
                {
                    answer = 100 * 100 * 101;
                }
                else
                {
                    answer = 10000 * n;
                }
            }
            Console.WriteLine(answer);
        }

        static void SolveC(string[] args)
        {
            string szLine = Console.ReadLine();
            int n = int.Parse(szLine);
            szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            long[] a = new long[szArr.Length];


            // 各数に対し、2^ki の倍数かを求め　ki を足し合わせるイメージ？
            int total = 0;
            for(int i=0;i<a.Length;++i)
            {
                long tmp = long.Parse(szArr[i]);
                a[i] = tmp;

                while ( tmp % 2 == 0)
                {
                    tmp /= 2;
                    total++;
                }
            }

            


            Console.WriteLine(total);
        }

        static void SolveD(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int n = int.Parse(szArr[0]);
            int m = int.Parse(szArr[1]);

            long[] x = new long[n];
            long[] y = new long[n];
            long[] z = new long[n];
            for (int i = 0; i < n; ++i)
            {
                szLine = Console.ReadLine();
                szArr = szLine.Split(' ');
                x[i] = long.Parse(szArr[0]);
                y[i] = long.Parse(szArr[1]);
                z[i] = long.Parse(szArr[2]);
            }

            // 8パターン
            long[] arr = new long[8];
            arr[0] = Calc(m, x, y, z, 1, 1, 1);
            arr[1] = Calc(m, x, y, z, 1, 1, -1);
            arr[2] = Calc(m, x, y, z, 1, -1, 1);
            arr[3] = Calc(m, x, y, z, 1, -1, -1);
            arr[4] = Calc(m, x, y, z, -1, 1, 1);
            arr[5] = Calc(m, x, y, z, -1, 1, -1);
            arr[6] = Calc(m, x, y, z, -1, -1, 1);
            arr[7] = Calc(m, x, y, z, -1, -1, -1);

            long max = arr.Max();
            Console.WriteLine(max);
        }
        private static long Calc(int m, long[] x, long[ ] y, long[] z, int opx, int opy, int opz)
        {
            long[] a = new long[x.Length];
            for( int i=0; i < x.Length;++i)
            {
                a[i] = opx * x[i] + opy * y[i] + opz * z[i];
            }
            a = a.OrderByDescending(p => p).ToArray();

            long max = 0;
            for(int i=0;i<m;++i)
            {
                max += a[i];
            }
            return max;
        }
    }

}


Measured memory_bytes: 13664