#include <bits/stdc++.h>
using namespace std;
int a[500][500];
int dp[500][500][500];
int main() {
  int h, w;
  cin >> h >> w;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) scanf("%d", &a[i][j]);
  }
  memset(dp, 0, sizeof(dp));
  dp[1][1][1] = a[1][1];
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      for (int k = 1; k <= i + j - 1 && k <= w; k++) {
        if (j == k) {
          dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k] + a[i + 1][j]);
          dp[i][j + 1][k + 1] =
              max(dp[i][j + 1][k + 1], dp[i][j][k] + a[i][j + 1]);
        } else {
          dp[i + 1][j][k] = max(
              dp[i + 1][j][k], dp[i][j][k] + a[i + 1][j] + a[i + j - k + 1][k]);
          dp[i][j + 1][k + 1] =
              max(dp[i][j + 1][k + 1],
                  dp[i][j][k] + a[i][j + 1] + a[i + j - k][k + 1]);
        }
        if (j == k + 1) {
          dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k] + a[i + 1][j]);
        } else {
          dp[i + 1][j][k + 1] =
              max(dp[i + 1][j][k + 1],
                  dp[i][j][k] + a[i + 1][j] + a[i + j - k][k + 1]);
        }
        if (j + 1 == k) {
          dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k] + a[i][j + 1]);
        } else {
          dp[i][j + 1][k] = max(
              dp[i][j + 1][k], dp[i][j][k] + a[i][j + 1] + a[i + j - k + 1][k]);
        }
      }
    }
  }
  cout << dp[h][w][w] << endl;
  return 0;
}
