{
TASK:apple
LANG:Pascal
}
var
a,b:array [1..70,1..70] of integer;
m,n,i,j,apps,max:integer;

procedure DFS2(i,j:integer);
begin
if (i>=1)and(j>=1) then
begin
apps:=apps+a[i,j];
if apps>max then max:=apps;

a[i,j]:=0;
DFS2(i-1,j);
DFS2(i,j-1);
a[i,j]:=b[i,j];
apps:=apps-a[i,j];

end;

end;




procedure DFS1(i,j:integer);
begin
if (i<=n)and(j<=m) then
begin
apps:=apps+a[i,j];

if apps>max then max:=apps;

a[i,j]:=0;
DFS1(i+1,j);
DFS1(i,j+1);
DFS2(i,j);
a[i,j]:=b[i,j];
apps:=apps-a[i,j];
end;


end;



begin

 read(m,n);

  for i:=1 to n do
   for j:=1 to m do
    read(a[i,j]);
    b:=a;

    DFS1(1,1);

writeln(max);




end.