#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m=map(int,input().split())\n"
"s=[list(map(int,input().split()))for _ in range(n)]\n"
"a=0\n"
"for i in range(1<<3):\n"
"    t=[[v for v in s[i]]for i in range(n)]\n"
"    for j in range(3):\n"
"        if i>>j&1:\n"
"            for k in range(n):\n"
"                t[k][j]*=-1\n"
"    for j in range(n):\n"
"        t[j]=sum(t[j])\n"
"    a=max(a,sum(sorted(t)[::-1][:m]))\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            