#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 1000;
int main()
{
  int n,m,i,j;
  long long x,y,z,res;
  long long rr[8][N_MAX],r[8];
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> x >> y >> z;
    rr[0][i]=x+y+z;
    rr[1][i]=x+y-z;
    rr[2][i]=x-y+z;
    rr[3][i]=x-y-z;
    rr[4][i]=-x+y+z;
    rr[5][i]=-x+y-z;
    rr[6][i]=-x-y+z;
    rr[7][i]=-x-y-z;
  }
  for(i=0;i<8;i++){
    r[i]=0;
    sort(rr[i],rr[i]+n,greater<long long>());
    for(j=0;j<m;j++)
      r[i]+=rr[i][j];
  }
  res=*max_element(r,r+8);
  cout << res << endl;
  return 0;
}