#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 62);
const int inf = (1 << 30);
const int nmax = 1e5 + 50;
const int mod = 1e9 + 7;
using namespace std;
int n, m, i, j, x, y, t, p, dx[] = {-1, 0}, dy[] = {0, -1};
long long a[35][35], f[35][35][35][35];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  f[1][1][1][1] = a[1][1];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      for (x = 1; x <= n; x++) {
        for (y = 1; y <= m; y++) {
          if (x + y != i + j) continue;
          for (t = 0; t < 2; t++) {
            for (p = 0; p < 2; p++) {
              f[i][j][x][y] = max(
                  f[i][j][x][y], f[i + dx[t]][j + dy[t]][x + dx[p]][y + dy[p]]);
            }
          }
          f[i][j][x][y] += a[i][j] + a[x][y];
          if (i == x && j == y) f[i][j][x][y] -= a[i][j];
        }
      }
    }
  }
  cout << f[n][m][n][m] << endl;
  return 0;
}
