#ifndef PRELUDE_HPP
#define PRELUDE_HPP

using ll = long long;

#ifndef GLOBALS_HPP_PAEGAYRI
#define GLOBALS_HPP_PAEGAYRI

#include <limits>

namespace pcl {
constexpr int INF    = std::numeric_limits<int>::max() / 2;
constexpr ll LNF     = std::numeric_limits<ll>::max() / 2;
constexpr double DNF = std::numeric_limits<double>::max() / 2;
constexpr double EPS = 1e-8;
constexpr int DX[]   = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int DY[]   = {0, 1, 0, -1, -1, 1, 1, -1};
} // namespace pcl

#endif /* end of include guard: GLOBALS_HPP_PAEGAYRI */

#ifndef ALIAS_HPP_ZFQX8TMN
#define ALIAS_HPP_ZFQX8TMN

#include <algorithm>
#include <cmath>

namespace pcl {
template <typename T>
void updmax(T &a, T const &b) {
  a = std::max(a, b);
}

template <typename T>
void updmin(T &a, T const &b) {
  a = std::min(a, b);
}

template <typename T, typename U, typename V>
bool in_range(T const &begin, U const &mid, V const &end) {
  return begin <= mid && mid < end;
}
template <typename T, typename U, typename V>
bool in_range(T const &begin, std::initializer_list<U> list, V const &end) {
  auto p = std::minmax_element(list.begin(), list.end());
  return begin <= *p.first && *p.second < end;
}
inline bool eqdbl(double a, double b) { return std::abs(a - b) < EPS; }
inline bool ledbl(double a, double b) { return a < b || eqdbl(a, b); }
inline bool gtdbl(double a, double b) { return a > b || eqdbl(a, b); }
} // namespace pcl

#endif /* end of include guard: ALIAS_HPP_ZFQX8TMN */

#ifndef ASSERT_HPP_LEUGNHXR
#define ASSERT_HPP_LEUGNHXR

#include <iostream>
#include <string>

#ifndef ALIAS_HPP_ZFQX8TMN
#define ALIAS_HPP_ZFQX8TMN

#include <algorithm>
#include <cmath>

namespace pcl {
template <typename T>
void updmax(T &a, T const &b) {
  a = std::max(a, b);
}

template <typename T>
void updmin(T &a, T const &b) {
  a = std::min(a, b);
}

template <typename T, typename U, typename V>
bool in_range(T const &begin, U const &mid, V const &end) {
  return begin <= mid && mid < end;
}
template <typename T, typename U, typename V>
bool in_range(T const &begin, std::initializer_list<U> list, V const &end) {
  auto p = std::minmax_element(list.begin(), list.end());
  return begin <= *p.first && *p.second < end;
}
inline bool eqdbl(double a, double b) { return std::abs(a - b) < EPS; }
inline bool ledbl(double a, double b) { return a < b || eqdbl(a, b); }
inline bool gtdbl(double a, double b) { return a > b || eqdbl(a, b); }
} // namespace pcl

#endif /* end of include guard: ALIAS_HPP_ZFQX8TMN */


namespace pcl {
template <typename Printer>
void _assert_failed(char const *expr, Printer showmsg, char const *file,
                    unsigned line) {
  std::cerr << "!!!!! Assertion Failed !!!!!" << std::endl;
  std::cerr << "  ---> `" << expr << "` at " << file << ", line " << line
            << std::endl;
  showmsg();
  abort();
}

#define DEFINE_ASSERT_XX(xx, cond_op)                                \
  template <typename T, typename U>                                  \
  void _assert_##xx(char const *expr1_str, char const *expr2_str,    \
                    T const &expr1, U const &expr2, char const *msg, \
                    char const *file, unsigned line) {               \
    if (!(expr1 cond_op expr2)) {                                    \
      std::string es =                                               \
          std::string(expr1_str) + " " #cond_op " " + expr2_str;     \
      auto printer = [&]() {                                         \
        if (msg[0] != 0) std::cerr << "  | " << msg << std::endl;    \
        std::cerr << "  | left:  " << expr1 << std::endl;            \
        std::cerr << "  | right: " << expr2 << std::endl;            \
      };                                                             \
      _assert_failed(es.c_str(), printer, file, line);               \
    }                                                                \
  }

DEFINE_ASSERT_XX(eq, ==)
DEFINE_ASSERT_XX(ne, !=)
DEFINE_ASSERT_XX(gt, >)
DEFINE_ASSERT_XX(lt, <)
DEFINE_ASSERT_XX(ge, >=)
DEFINE_ASSERT_XX(le, <=)

template <typename T, typename U, typename V>
void _assert_range(T const &begin, char const *mid_str, U const &mid,
                   V const &end, char const *msg, char const *file,
                   unsigned line) {
  if (!in_range(begin, mid, end)) {
    std::string es = "";
    es += std::to_string(begin) + " <= " + mid_str + " (" +
          std::to_string(mid) + ") < " + std::to_string(end);
    auto printer = [&]() {
      std::cerr << "  | variable is not in range." << std::endl;
      if (msg[0] != 0) std::cerr << "  | " << msg << std::endl;
    };
    _assert_failed(es.c_str(), printer, file, line);
  }
}

#undef DEFINE_ASSERT_XX
} // namespace pcl

#ifdef NOASSERT
#define ASSERT(...)
#define ASSERT_RANGE(...)
#define ASSERT_EQ(...)
#define ASSERT_NE(...)
#define ASSERT_GT(...)
#define ASSERT_LT(...)
#define ASSERT_GE(...)
#define ASSERT_LE(...)
#else
#define ASSERT(expr, msg)                                               \
  (void)(!(expr) && (pcl::_assert_failed(#expr,                         \
                                         [&]() {                        \
                                           if ((msg)[0] != 0)           \
                                             std::cerr << "  | " << msg \
                                                       << std::endl;    \
                                         },                             \
                                         __FILE__, __LINE__),           \
                     0))
#define ASSERT_RANGE(begin, mid, end, msg) \
  pcl::_assert_range(begin, #mid, mid, end, msg, __FILE__, __LINE__)
#define CALL_ASSERT_XX(xx, expr1, expr2, msg) \
  pcl::_assert_##xx(#expr1, #expr2, expr1, expr2, msg, __FILE__, __LINE__)
#define ASSERT_EQ(expr1, expr2, msg) CALL_ASSERT_XX(eq, expr1, expr2, msg)
#define ASSERT_NE(expr1, expr2, msg) CALL_ASSERT_XX(ne, expr1, expr2, msg)
#define ASSERT_GT(expr1, expr2, msg) CALL_ASSERT_XX(gt, expr1, expr2, msg)
#define ASSERT_LT(expr1, expr2, msg) CALL_ASSERT_XX(lt, expr1, expr2, msg)
#define ASSERT_GE(expr1, expr2, msg) CALL_ASSERT_XX(ge, expr1, expr2, msg)
#define ASSERT_LE(expr1, expr2, msg) CALL_ASSERT_XX(le, expr1, expr2, msg)
#endif

#endif /* end of include guard: ASSERT_HPP_LEUGNHXR */

#ifndef DEBUG_HPP_OB5Y82L9
#define DEBUG_HPP_OB5Y82L9

#ifdef PA_DEBUG
#define PD(stmt) stmt
#else
#define PD(stmt)
#endif

#ifdef PA_DEBUG_LIB
#define PD_LIB(stmt) stmt
#else
#define PD_LIB(stmt)
#endif

#endif /* end of include guard: DEBUG_HPP_OB5Y82L9 */

#ifndef STREAM_OVERLOADS_HPP_DNIKPKZJ
#define STREAM_OVERLOADS_HPP_DNIKPKZJ

#include <iostream>
#include <vector>
namespace pcl {
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> const &v) {
  os << '[';
  for (size_t i = 0; i < v.size(); i++) {
    if (i != 0) os << ", ";
    os << v[i];
  }
  os << ']';
  return os;
}

template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
  for (size_t i = 0; i < v.size(); i++) is >> v[i];
  return is;
}
} // namespace pcl

#endif /* end of include guard: STREAM_OVERLOADS_HPP_DNIKPKZJ */


#endif /* end of include guard: PRELUDE_HPP */


#include <bits/stdc++.h>
using namespace std;
using namespace pcl;

struct cake {
    ll looks, taste, known;
};
int main() {
    int N, M;
    cin >> N >> M;

    vector<cake> cakes(N);
    for (auto &c : cakes) { cin >> c.looks >> c.taste >> c.known; }

    ll ma = 0;
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) {
            for (int k = -1; k <= 1; k += 2) {
                vector<ll> sum(N);
                for (int l = 0; l < N; l++) {
                    auto &c = cakes[l];
                    sum[l]  = c.looks * i + c.taste * j + c.known * k;
                }
                sort(sum.begin(), sum.end(), greater<ll>());
                ll ans = 0;
                for (int l = 0; l < M; l++) { ans += sum[l]; }
                updmax(ma, ans);
            }
        }
    }
    cout << ma << endl;
}



Measured memory_bytes: 256