#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[3][1005];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld", &a[0][i], &a[1][i], &a[2][i]);
	}
	LL ans = -1e18;
	for(int i=0;i<8;i++){
		vector<LL> res;
		for(int j=1;j<=n;j++){
			LL cost = 0;
			for(int k=0;k<3;k++){
				if((i>>k)&1) cost += a[k][j];
				else cost -= a[k][j];
			}
			res.push_back(cost);
		}
		sort(res.begin(), res.end());
		reverse(res.begin(), res.end());
		LL tmp = 0;
		for(int j=0;j<m;j++){
			tmp += res[j];
		}
		ans = max(ans, tmp);
	}

	printf("%lld\n", ans);
}