#include<iostream>
#include<algorithm>
using namespace std;
int dp[40][40][40][40],H,W,a[40][40];
int main(){
cin>>H>>W;
for(int i=0;i<H;i++){for(int j=0;j<W;j++){cin>>a[i][j];}}
dp[0][0][0][0]=a[0][0];
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
for(int k=0;k<H;k++){
for(int l=0;l<W;l++){
if(i+1==k+1 && j==l){dp[i+1][j][k+1][l]=max(dp[i+1][j][k+1][l],dp[i][j][k][l]+a[i+1][j]);}
if(i+1==k && j==l+1){dp[i+1][j][k][l+1]=max(dp[i+1][j][k][l+1],dp[i][j][k][l]+a[i+1][j]);}
if(i==k+1 && j+1==l){dp[i][j+1][k+1][l]=max(dp[i][j+1][k+1][l],dp[i][j][k][l]+a[i][j+1]);}
if(i==k && j+1==l+1){dp[i][j+1][k][l+1]=max(dp[i][j+1][k][l+1],dp[i][j][k][l]+a[i][j+1]);}
if(i+1!=k+1 || j!=l){dp[i+1][j][k+1][l]=max(dp[i+1][j][k+1][l],dp[i][j][k][l]+a[i+1][j]+a[k+1][l]);}
if(i+1!=k || j!=l+1){dp[i+1][j][k][l+1]=max(dp[i+1][j][k][l+1],dp[i][j][k][l]+a[i+1][j]+a[k][l+1]);}
if(i!=k+1 || j+1!=l){dp[i][j+1][k+1][l]=max(dp[i][j+1][k+1][l],dp[i][j][k][l]+a[i][j+1]+a[k+1][l]);}
if(i!=k || j+1!=l+1){dp[i][j+1][k][l+1]=max(dp[i][j+1][k][l+1],dp[i][j][k][l]+a[i][j+1]+a[k][l+1]);}
}
}
}
}
cout<<dp[H-1][W-1][H-1][W-1]<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGRwWzQwXVs0MF1bNDBdWzQwXSxILFcsYVs0MF1bNDBdOwppbnQgbWFpbigpewoJY2luPj5IPj5XOwoJZm9yKGludCBpPTA7aTxIO2krKyl7Zm9yKG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