#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=104;
int f[maxn][maxn][maxn],n,m,a[maxn][maxn];
int MY()
{
freopen("message.in","r",stdin);
freopen("message.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&a[i][j]);
int ans=0;
int v=m+n-2;
for(int d=1;d<=v;d++)
for(int i1=1;i1<=n;i1++)
for(int i2=1;i2<=n;i2++){
if(i1==i2)continue;
int x1=f[d-1][i1][i2];
int x2=f[d-1][i1-1][i2];
int x3=f[d-1][i1][i2-1];
int x4=f[d-1][i1-1][i2-1];
int a1=max(x1,x2),a2=max(x3,x4);
f[d][i1][i2]=max(a1,a2)+a[i1][d+2-i1]+a[i2][d+2-i2];
if(ans<f[d][i1][i2])ans=f[d][i1][i2];
}
printf("%d",ans);
return 0;
}
int YOU=MY();
int main(){;}