program P266;
var
a,b,c:array[1..20000] of longint;
i,j,k,sum,n,m,ls,w:longint;
begin
assign(input,'perfecttour.in');
reset(input);
assign(output,'perfecttour.out');
rewrite(output);
readln(m,n);
for i:=1 to n-1 do
begin
read(a[i]);
b[i]:=a[i];
end;
readln;
for i:=2 to m do
begin
for j:=1 to n-1 do
begin
read(a[j]);
if a[j]>b[j] then b[j]:=a[j];
end;
readln;
end;
for i:=1 to n-1 do
c[i]:=-maxlongint;
for i:=1 to n-1 do
begin
ls:=ls+b[i];
if ls>c[1] then begin c[1]:=ls; w:=i; end;
end;
for i:=2 to n-1 do if w<=i then c[i]:=b[i] else c[i]:=c[i-1]-b[i-1];
for i:=1 to n-1 do if c[i]>sum then sum:=c[i];
writeln(sum);
end.