#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-8;
const double inf = 1e8;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > in(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> in[i][j];
  if (n <= 2 || m <= 2) {
    int out = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) out += in[i][j];
    cout << out << endl;
    return 0;
  }
  vector<int> dp(20010);
  dp[200] = in[0][0] + in[1][0] + in[0][1] + in[n - 1][m - 1];
  for (int i = 2; i < n + m - 2; i++) {
    vector<int> tmp(20010);
    for (int j = 0; j < 20010; j++)
      if (dp[j]) {
        int l = j % 200, r = j / 200;
        for (int q1 = 0; q1 < 2; q1++)
          for (int q2 = 0; q2 < 2; q2++) {
            int L = l + q1, R = r + q2;
            if (i - L == n || L == R || R == m) continue;
            tmp[L + 200 * R] =
                max(tmp[L + 200 * R], dp[j] + in[i - L][L] + in[i - R][R]);
          }
      }
    dp = tmp;
  }
  cout << dp[(m - 2) + (m - 1) * 200] << endl;
}
