### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, XYZ):

    cakes = []

    # for x, y, z in XYZ:
    #     cakes.append((abs(x) + abs(y) + abs(z), x, y, z))
    # cakes.sort(reverse=True)

    def v(xyz):
        return abs(xyz[0]) + abs(xyz[1]) + abs(xyz[2])

    take = list(range(M))
    V = 0
    f = True
    while f:
        f = False
        X = Y = Z = 0
        for i in take:
            x, y, z = XYZ[i]
            X += x
            Y += y
            Z += z

        V = v((X, Y, Z))
        IJ = None
        for i in range(N):
            if i in take:
                continue
            for j in take:
                C = (X - XYZ[j][0] + XYZ[i][0], Y - XYZ[j][1] + XYZ[i][1],
                     Z - XYZ[j][2] + XYZ[i][2])
                if V < v(C):
                    V = v(C)
                    IJ = (i, j)
        if IJ:
            take.remove(IJ[1])
            take.append(IJ[0])
            f = True

    return V


def main():
    N, M = read_int_n()
    XYZ = [read_int_n() for _ in range(N)]
    print(slv(N, M, XYZ))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, XYZ):
    ans = 0
    for i, j, k in product([-1, 1], [-1, 1], [-1, 1]):
        ans = max(ans,
                  sum(
                      sorted(
                          [i * x + j * y + k * z for x, y, z in XYZ],
                          reverse=True)[:M]))
    return ans


def main():
    N, M = read_int_n()
    XYZ = [read_int_n() for _ in range(N)]

    print(slv(N, M, XYZ))


if __name__ == '__main__':
    main()