#include <bits/stdc++.h>
using namespace std;

#define int long long

int x[1005], y[1005], z[1005];
int sum[9][1005];

signed main()
{
	int n, m;
	scanf ("%lld%lld", &n, &m);
	for (int i=1; i<=n; i++){
		scanf ("%lld%lld%lld", &x[i], &y[i], &z[i]);
		sum[1][i] = x[i] + y[i] + z[i];
		sum[2][i] = x[i] + y[i] - z[i];
		sum[3][i] = x[i] - y[i] + z[i];
		sum[4][i] = -x[i] + y[i] + z[i];
		sum[5][i] = x[i] - y[i] - z[i];
		sum[6][i] = -x[i] + y[i] - z[i];
		sum[7][i] = -x[i] - y[i] + z[i];
		sum[8][i] = -x[i] - y[i] - z[i];
	}
	
	int ans=0;
	for (int i=1; i<=8; i++){
		sort (sum[i]+1, sum[i]+n+1);
		int cnt=0;
		for (int j=1; j<=m; j++){
			cnt += sum[i][n-j+1];
		}
		
		ans = max (ans, cnt);
	}
	
	printf ("%d\n", ans);
	return 0;
}