#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#define LL long long
using namespace std;
int max(int x, int y, int k, int l)
{
int m = x > y ? x : y;
m = m > k ? m : k;
m = m > l ? m : l;
return m;
}
int dp[55][55][55][55] = { 0 }; //i + j = k + l;
int main()
{
int n, m, map[55][55], i, j, k, l;
while( scanf("%d%d", &n, &m)!=EOF)
{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
scanf("%d", &map[i][j]);
}
}
if(m<2|| n<2)
{
printf("0\r\n");
continue;
}
for(i = 1;i <= n;i++)
{
for (j = 1; j <= m; j++)
{
for (k = i+1; k <= n; k++) //i+1保证他们不会有交集
{
l = i + j - k;
if (l>m||l<=0)
{
continue;
}
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-1][l],dp[i][j-1][k][l-1])+map[i][j]+map[k][l];
}
}
}
printf("%d\r\n",dp[n-1][m][n][m-1]);
}
return 0;
}