#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC100D_PatisserieABC();

#if 1
int main()
{
	ABC100D_PatisserieABC();
	fflush(stdout);
	return 0;
}
#endif

class ABC100D_data {
public:
	LLONG bty = 0;
	LLONG tst = 0;
	LLONG ppl = 0;

	void add (const ABC100D_data& a) {
		bty += a.bty;
		tst += a.tst;
		ppl += a.ppl;
	}

	LLONG getAbs() {
		return (tp_abs<LLONG>(bty) + tp_abs<LLONG>(tst) + tp_abs<LLONG>(ppl));
	}

	static bool dsc_ppp(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.bty + a.tst + a.ppl) > (b.bty + b.tst + b.ppl);
	}

	static bool dsc_ppm(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.bty + a.tst - a.ppl) > (b.bty + b.tst - b.ppl);
	}

	static bool dsc_pmp(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.bty - a.tst + a.ppl) > (b.bty - b.tst + b.ppl);
	}

	static bool dsc_mpp(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.tst + a.ppl - a.bty) > (b.tst + b.ppl - b.bty);
	}

	static bool dsc_mmp(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.ppl - a.bty - a.tst) > (b.ppl - b.bty - b.tst);
	}

	static bool dsc_mpm(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.tst - a.ppl - a.bty) > (b.tst - b.ppl - b.bty);
	}

	static bool dsc_pmm(const ABC100D_data& a, const ABC100D_data& b) {
		return (a.bty - a.tst - a.ppl) > (b.bty - b.tst - b.ppl);
	}
	
	static bool dsc_mmm(const ABC100D_data& a, const ABC100D_data& b) {
		return (- a.bty - a.tst - a.ppl) > (- b.bty - b.tst - b.ppl);
	}
};

static LLONG ABC100D_judge(std::vector<ABC100D_data>& cake, int M) {
	bool  (*judge[8])(const ABC100D_data&, const ABC100D_data&) =
	{
		ABC100D_data::dsc_ppp,
		ABC100D_data::dsc_ppm,
		ABC100D_data::dsc_pmp,
		ABC100D_data::dsc_mpp,
		ABC100D_data::dsc_mmp,
		ABC100D_data::dsc_mpm,
		ABC100D_data::dsc_pmm,
		ABC100D_data::dsc_mmm
	};

	LLONG ans = 0;
	for (int i = 0; i < 8; i++) {
		std::sort(cake.begin(), cake.end(), judge[i]);

		ABC100D_data tmp;
		for (int j = 0; j < M; j++) {
			tmp.add(cake[j]);
		}

		ans = tp_max<LLONG>(ans, tmp.getAbs());
	}
	return ans;
}
static void ABC100D_PatisserieABC()
{
	int N, M;
	get2int(N, M);

	std::vector<ABC100D_data> cake(N);

	for (int i = 0; i < N; i++) {
		get3int<LLONG>(cake[i].bty, cake[i].tst, cake[i].ppl);
	}
	printf("%lld\n", ABC100D_judge(cake, M));
}


Measured memory_bytes: 256