text: /*************************************************************************
  >>> Author: WindCry1
  >>> Mail: lanceyu120@gmail.com
  >>> Website: https://windcry1.com
  >>> Date: 12/30/2019 11:03:37 PM
  *************************************************************************/
  #include <cstring>
  #include <cmath>
  #include <cstdio>
  #include <cctype>
  #include <cstdlib>
  #include <ctime>
  #include <vector>
  #include <iostream>
  #include <string>
  #include <queue>
  #include <set>
  #include <map>
  #include <algorithm>
  #include <complex>
  #include <stack>
  #include <bitset>
  #include <iomanip>
  #include <list>
  #include <sstream>
  #include <fstream>
  #if __cplusplus >= 201103L
  #include <unordered_map>
  #include <unordered_set>
  #endif
  #define endl '\n'
  #define ll long long
  #define ull unsigned long long
  #define DEBUG(x) cout<<#x<<" : "<<x<<endl;
  #define lowbit(x) x&(-x)
  #define ls u<<1
  #define rs u<<1|1
  using namespace std;
  template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
  template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
  template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
  template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  const double eps = 1e-8;
  const int INF = 0x3f3f3f3f;
  const int mod = 1e9+7;
  const int dir[4][2]={-1,0,1,0,0,-1,0,1};
  int a[60][60],dp[60][60][60][60];
  int main(){
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  #ifdef WindCry1
  	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
  #endif
  	int n,m;cin>>n>>m;
  	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i][j];
  	for(int i=1;i<=n;i++)
  		for(int j=1;j<=m;j++)
  			for(int k=1;k<=n;k++)
  				for(int l=1;l<=m;l++)
  					dp[i][j][k][l]=MAX(dp[i-1][j][k-1][l],dp[i-1][j][k][l-1],dp[i][j-1][k][l-1],dp[i][j-1][k-1][l])+a[i][j]+(i==k&&j==l?0:a[k][l]);
  	cout<<dp[n][m][n][m]<<endl;
  	return 0;
  }
  
  
  