#include <bits/stdc++.h>

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T>
auto make_vector(int n, int m, const T &value){
  return std::vector<std::vector<T>>(n, std::vector<T>(m, value));
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}



namespace solver{
  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }
  
  void solve(){
    int N, M; std::cin >> N >> M;
    auto A = make_vector<int64_t>(N, M, 0);
    std::cin >> A;

    std::deque<int64_t> B(N);
    for(int i = 0; i < N; ++i) B[i] = std::accumulate(A[i].begin(), A[i].end(), 0LL);

    auto dp = make_vector<int64_t>(2, N + 1, -(1LL << 50));

    dp[0][0] = 0;

    for(int i = 0; i < N; ++i){
      chmax(dp[0][i + 1], dp[0][i]);
      chmax(dp[1][i + 1], dp[0][i] + B[i]);
      chmax(dp[1][i + 1], dp[1][i]);
      chmax(dp[0][i + 1], dp[1][i] - B[i]);
    }

    int64_t ans = std::max(dp[0][N], dp[1][N]);    
    
    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}