#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, d[205][205];
long long a[205][205], f[205][205], ans;
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];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (j - 1 >= 1 && f[i][j - 1] > f[i - 1][j]) {
        f[i][j] = f[i][j - 1];
        d[i][j] = 0;
      } else {
        f[i][j] = f[i - 1][j];
        d[i][j] = 1;
      }
      f[i][j] += a[i][j];
    }
  }
  ans = f[n][m];
  i = n, j = m;
  while (1) {
    a[i][j] = 0;
    if (i == 1 && j == 1) break;
    if (d[i][j])
      i--;
    else
      j--;
  }
  memset(f, 0, sizeof(f));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) f[i][j] = max(f[i - 1][j], f[i][j - 1]) + a[i][j];
  cout << f[n][m] + ans << endl;
  return 0;
}
