#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
using namespace std;
long long k[1005][5], ans;
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> k[i][j];
		}
	}
  
	for (int i = 0; i < (1<<3); ++i) {
		long long sum = 0, mon[100005] = {};
		for (int j = 0; j < a; ++j) {
			for (int kk = 0; kk < 3; ++kk) {
				if (i / (1 << kk) % 2 == 0) {mon[j] += k[j][kk];}
				else {mon[j] -= k[j][kk];}
			}
		}
		sort(mon, mon + a);
		for (int j = a - 1; j >= a - b; --j) {
			sum += mon[j];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}