// -*- coding:utf-8-unix -*-

#![allow(dead_code)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
// const MOD: i64 = 998244353;

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {


    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn solve() {
    let (n, m) = readuu();
    let mut data: Vec<(i64, i64, i64)> = vec![(0, 0, 0); 0];
    for i in 0..n {
        let (a, b, c) = readiii();
        data.push((a, b, c));
    }
    let mut res = -1 * INF;
    let mut u: usize = 3;
    for bit in 0..(1 << u) {
        let mut vec = vec![0; 0];
        for j in 0..u {
            vec.push((bit >> j) & 1);
        }
        // println!("{:?}", vec);
        let mut data2 = vec![(0, 0, 0, 0); n];
        for i in 0..n {
            data2[i].1 = if vec[0] == 0 {
                data[i].0
            } else {
                data[i].0 * -1
            };

            data2[i].2 = if vec[1] == 0 {
                data[i].1
            } else {
                data[i].1 * -1
            };

            data2[i].3 = if vec[2] == 0 {
                data[i].2
            } else {
                data[i].2 * -1
            };

            data2[i].0 = data2[i].1 + data2[i].2 + data2[i].3;
            // data2[i].0 = data2[i].0.abs();
        }
        data2.sort();
        data2.reverse();

        let mut s1: i64 = 0;
        let mut s2: i64 = 0;
        let mut s3: i64 = 0;
        for i in 0..m {
            s1 += data2[i].1;
            s2 += data2[i].2;
            s3 += data2[i].3;
            // println!("{:?}", (data2[i].1, data2[i].2, data2[i].3));
        }
        res = max(res, s1.abs() + s2.abs() + s3.abs());
    }
    println!("{}", res);
}
fn main() {
    solve()
}


Measured memory_bytes: 2220