#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool isprime[1000000 + 5];
void init_prime() {
  fill(isprime, isprime + 1000000 + 5, true);
  isprime[0] = isprime[1] = false;
  for (int i = (0), loop_end_i = (1000000 + 5); i < (loop_end_i); i++) {
    if (isprime[i]) {
      for (int j = i * 2; j < 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
}
vector<long long> factors(long long n) {
  vector<long long> v;
  for (long long i = (0), loop_end_i = (1000000); i < (loop_end_i); i++) {
    if (!isprime[i]) continue;
    while (n % i == 0) {
      v.push_back(i);
      n /= i;
    }
  }
  if (n > 1) {
    v.push_back(n);
  }
  return v;
}
template <typename T = int>
class bit {
 public:
  T *bit_arr;
  int size;
  bit(int n) {
    size = n;
    bit_arr = new T[n];
    fill(bit_arr, bit_arr + n, 0);
  }
  ~bit() { delete bit_arr; }
  T sum(int a) {
    T ret = 0;
    while (a) {
      ret += bit_arr[a];
      a -= a & -a;
    }
    return ret;
  }
  T sum(int a, int b) { return sum(b) - sum(a); }
  T get(int a) { return sum(a, a + 1); }
  void add(int a, T x) {
    a++;
    while (a < size) {
      bit_arr[a] += x;
      a += a & -a;
    }
  }
  void set(int a, T x) { add(a, x - get(a)); }
};
template <typename T = int, class Compare = less<T> >
class rmq {
 public:
  int size;
  Compare comp;
  T *dat;
  T init;
  rmq(int n, T init_ = INT_MAX) {
    init = init_;
    size = 1;
    while (size < n) size *= 2;
    dat = new T[2 * size - 1];
    fill(dat, dat + (2 * size - 1), init);
  }
  ~rmq() { delete dat; }
  void set(int k, T a) {
    k += size - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2], comp);
    }
  }
  T get(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return init;
    if (a <= l && r <= b)
      return dat[k];
    else {
      T vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr, comp);
    }
  }
  T get(int a, int b) { return get(a, b, 0, 0, size); }
};
int h, w;
int memo[250][250][250];
int x[250][250];
inline int sm(int a, int b, int c) { return x[a][c + 1] - x[a][b]; }
int DP(int, int, int);
inline int dp(int a, int b, int c) {
  if (~memo[a][b][c])
    return memo[a][b][c];
  else
    return memo[a][b][c] = DP(a, b, c);
}
int DP(int a, int b, int c) {
  int ret = 0;
  if (a == h - 1) {
    ret = sm(a, min(b, c), w - 1);
  } else {
    for (int d = (b), loop_end_d = (w); d < (loop_end_d); d++) {
      for (int e = (max(c, d)), loop_end_e = (w); e < (loop_end_e); e++) {
        int s = sm(a, b, d) + sm(a, c, e);
        if (c <= d) s -= sm(a, c, d);
        ((ret) = max((ret), (s + dp(a + 1, d, e))));
      }
    }
  }
  return ret;
}
int main() {
  {
    scanf("%d", &(h));
    scanf("%d", &(w));
  };
  for (int i = (0), loop_end_i = (250); i < (loop_end_i); i++)
    for (int j = (0), loop_end_j = (250); j < (loop_end_j); j++)
      for (int k = (0), loop_end_k = (250); k < (loop_end_k); k++)
        memo[i][j][k] = -1;
  for (int i = (0), loop_end_i = (h); i < (loop_end_i); i++) {
    x[i][0] = 0;
    for (int j = (0), loop_end_j = (w); j < (loop_end_j); j++) {
      int a;
      { scanf("%d", &(a)); };
      x[i][j + 1] = x[i][j] + a;
    }
  }
  printf("%d\n", dp(0, 0, 0));
}
