#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int m, n, a[55][55];
int f[55 * 2][55][55];
int main() {
  cin >> m >> n;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  }
  for (int k = 1; k <= m + n; k++) {
    for (int i = 1; i <= k - 1; i++) {
      for (int j = 1; j <= k - 1; j++) {
        int s1 = 0, s2 = 0;
        if (i != j) {
          s1 = max(f[k - 1][i - 1][j], f[k - 1][i][j - 1]);
          s2 = max(f[k - 1][i][j], f[k - 1][i - 1][j - 1]);
          f[k][i][j] = max(s1, s2) + a[i][k - i] + a[j][k - j];
        } else {
          s1 = max(f[k - 1][i - 1][j], f[k - 1][i][j - 1]);
          s2 = max(f[k - 1][i][j], f[k - 1][i - 1][j - 1]);
          f[k][i][j] = max(s1, s2) + a[i][k - i];
        }
      }
    }
  }
  cout << f[m + n][m][m] << endl;
}
