#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N  =1010;

int n , m;
int a,b,c;
bool vis[N][N];
ll mem[N][N];
ll x[N],y[N],z[N];

ll dp(int i,int j){
if( j == m )return 0ll;
if( i == n )return -(1ll<<50);

if( vis[i][j] )return mem[i][j];
vis[i][j]=1;
mem[i][j]=dp(i+1,j);

if( j < m )
    mem[i][j]=max( mem[i][j] , dp(i+1,j+1)+a*x[i]+b*y[i]+c*z[i] );
return mem[i][j];
}

int main(){

scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)scanf("%lld %lld %lld",x+i,y+i,z+i);
ll ans =0;

for(a=-1;a<2;a+=2)
for(b=-1;b<2;b+=2)
for(c=-1;c<2;c+=2){
    memset(vis,0,sizeof vis);
    ans=max(ans,dp(0,0));
}
printf("%lld\n",ans);
return 0;
}
