program rq400;
var
f:array [1..99,0..51,0..51] of longint;
num:array [1..99,0..51] of longint;
n,m,i,j,k,p,q,x,y:longint;
function max(a,b,c,d:longint):longint;
begin
if a>b then max:=a
else max:=b;
if c>max then max:=c;
if d>max then max:=d;
end;
begin
readln(m,n);
for i:=1 to m do
for j:=1 to n do
begin
read(k);
p:=i+j-1;
if p<=m then q:=j else q:=j-(p-m);
num[p,q]:=k;
end;
f[1,1,1]:=num[1,1];
p:=0;
for i:=2 to m do
for x:=1 to i do
for y:=1 to i do
begin
p:=max(f[i-1,x-1,y],f[i-1,x-1,y-1],f[i-1,x,y-1],f[i-1,x,y]);
if x=y then f[i,x,y]:=p+num[i,x]
else f[i,x,y]:=p+num[i,x]+num[i,y];
end;
for i:=m+1 to n-1 do
for x:=1 to m do
for y:=1 to m do
begin
p:=max(f[i-1,x,y],f[i-1,x,y+1],f[i-1,x+1,y],f[i-1,x+1,y+1]);
if x=y then f[i,x,y]:=p+num[i,x]
else f[i,x,y]:=p+num[i,x]+num[i,y];
end;
for i:=n to n+m-1 do
for x:=1 to n+m-i do
for y:=1 to n+m-i do
begin
p:=max(f[i-1,x,y],f[i-1,x,y+1],f[i-1,x+1,y],f[i-1,x+1,y+1]);
if x=y then f[i,x,y]:=p+num[i,x]
else f[i,x,y]:=p+num[i,x]+num[i,y];
end;
writeln(f[n+m-1,1,1]);
readln; readln;
end.