#include <cstdio>
int n , m , a[51][51] , f[51][51][51] ;
int max(int a,int b)
{
if (a > b)return a ;
else return b ;
}
int main()
{
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]);
for (int i = 1 ; i <= n ; i ++ )
{
for (int j = 2 ; j <= m ; j ++ )
{
for(int k = i + 1 ; k < i + j && k <= n ; k ++ )
{
int l = i + j - k ;
f[i][j][k] = max( max(f[i-1][j][k],f[i-1][j][k-1]), max(f[i][j-1][k],f[i][j-1][k-1]));
f[i][j][k] += ( a[i][j] + a[k][l] ) ;
}
}
}
printf("%d",f[n-1][m][n]) ;
}