program number;
var
m,n,i,j,max:longint;
table:array[1..30,1..30]of longint;
procedure find(x,y,data:longint);
begin
data:=data+table[x,y];
if (x=m)and(y=n) then begin
if max<0 then begin
if data>0 then max:=data;
end
else if (data>0)and(data<max) then max:=data;
end
else begin
if x<m then find(x+1,y,data);
if y<n then find(x,y+1,data);
end;
end;
begin
assign(input,'number.in');
assign(output,'number.out');
reset(input);
rewrite(output);
readln(m,n);
for i:=1 to m do
begin
for j:=1 to n do
read(table[i,j]);
readln;
end;
max:=-1;
find(1,1,0);
writeln(max);
close(input);
close(output);
end.