#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> X(N), Y(N), Z(N);
  REP(i, 0, N) cin >> X[i] >> Y[i] >> Z[i];

  ll ans = -(1LL << 60);
  REP(s, -1, 2) if (s != 0) {
    REP(t, -1, 2) if (t != 0) {
      REP(u, -1, 2) if (u != 0) {
        vector<ll> v(N);
        REP(i, 0, N) v[i] = s * X[i] + t * Y[i] + u * Z[i];
        sort(v.begin(), v.end());
        ll w = 0;
        REP(i, 0, M) w += v[N - i - 1];
        ans = max(ans, w);
      }
    }
  }
  cout << ans << endl;
}