{
TASK:apple
LANG:Pascal
}
program APPLE;


const
 maxM = 70;
 maxSt = 149;

type
 masiv = array[1..maxM, 1..MaxM] of word;
 stack = array[1..maxSt] of word;

var
 M,N,i,j: byte;
 T: masiv;
 app: longint;
 s: stack;
 si: byte;

procedure ClearStack(var st: stack; var i: byte);
begin
 i:=1;
 while i<=maxSt do
 begin
  if st[i]=0 then break;
  st[i]:=0;
 end;
 i:=0;
end;

procedure DeleteStack(var st: stack; var i: byte);
begin
 st[i]:=0;
 i:=i-1;
end;

procedure AddStack(var st: stack; var i: byte; a: word);
begin
 i:=i+1;
 st[i]:=a;
end;

procedure CopyStack(var st1: stack; var st2: stack);
var
 i: byte;
begin
 for i:=1 to maxSt do
  st2[i]:=st1[i];
end;

function FindPath(a,b: byte; inclst: boolean; var st: stack; var i: byte): longint;
var
 stubst: stack;
 sti: byte;
 maxapples,stubapples: longint;
begin
 if inclst then
  ClearStack(st,i);
 maxapples:=0;
 sti:=0;
 if (a<M) then
 begin
  stubapples:=FindPath(a+1,b,inclst,stubst,sti);
  if maxapples<stubapples then
  begin
   maxapples:=stubapples;
   if inclst then
    CopyStack(stubst,st);
  end;
 end;
 if (b<N) then
 begin
  stubapples:=FindPath(a,b+1,inclst,stubst,sti);
  if maxapples<stubapples then
  begin
   maxapples:=stubapples;
   if inclst then
    CopyStack(stubst,st);
  end;
 end;
 if inclst then
  AddStack(st,sti,(a-1)+(b-1)*M);
 FindPath:=maxapples+T[a,b];
 i:=sti;
end;

procedure ProcessStack(var st: stack; var i: byte);
var
 a,b: byte;
begin
 while i>0 do
 begin
  b:=(st[i] div M)+1;
  a:=(st[i] mod M)+1;
  T[a,b]:=0;
  DeleteStack(st,i);
 end;
end;

begin
 readln(M,N);
 for i:=1 to M do
 begin
  for j:=1 to N do
   read(T[i,j]);
  readln;
 end;
 app:=FindPath(1,1,true,s,si);
 ProcessStack(s,si);
 app:=app+FindPath(1,1,false,s,si);
 writeln(app);
end.