#include <bits/stdc++.h>
using namespace std;
const int N = 30;
int h, w;
int a[N][N];
int dp[N][N][N][N];
int dx1[] = {1, 0, 1, 0}, dy1[] = {0, 1, 0, 1};
int dx2[] = {1, 1, 0, 0}, dy2[] = {0, 0, 1, 1};
int dfs(int X1, int Y1, int X2, int Y2) {
  if (dp[X1][Y1][X2][Y2] != -1) return dp[X1][Y1][X2][Y2];
  int res = 0;
  res += a[Y1][X1];
  if (X1 != X2 || Y1 != Y2) res += a[Y2][X2];
  int ma = 0;
  for (int i = (0); i < (4); ++i) {
    int nx1 = X1 + dx1[i], ny1 = Y1 + dy1[i];
    int nx2 = X2 + dx2[i], ny2 = Y2 + dy2[i];
    if (nx1 < 0 || nx1 >= w || ny1 < 0 || ny1 >= h || nx2 < 0 || nx2 >= w ||
        ny2 < 0 || ny2 >= h)
      continue;
    ma = max(ma, dfs(nx1, ny1, nx2, ny2));
  }
  return dp[X1][Y1][X2][Y2] = res + ma;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  for (int i = (0); i < (h); ++i)
    for (int j = (0); j < (w); ++j) cin >> a[i][j];
  for (int i = (0); i < (N); ++i)
    for (int j = (0); j < (N); ++j)
      for (int k = (0); k < (N); ++k)
        for (int l = (0); l < (N); ++l) dp[i][j][k][l] = -1;
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}
