#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int maxn = 1e3 + 5;
const int MAX = 10000000;
ll x[maxn],y[maxn],z[maxn];
ll ans=-(1LL<<60);
int n,m;
ll sum;
int main()
{
   cin>>n>>m;
   for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];
   for(int i=0;i<8;i++)
   {
    int o1=(i&1)?1:-1;
    int o2=(i&2)?1:-1;
    int o3=(i&4)?1:-1;
    sum=0;
    vector<ll>vec;
    for(int i=0;i<n;i++)
      vec.push_back(x[i]*o1+y[i]*o2+z[i]*o3);
    sort(vec.rbegin(),vec.rend());
    for(int i=0;i<m;i++)sum+=vec[i];
      ans=max(ans,sum);
   }
   cout<<ans;
}
