#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,m,i,j,ans;
int l[110][20010]={0};
int c[20010]={0},s[20010]={0};
inline int max(int a,int b){return (a>b)?a:b;}
int main(){
freopen("perfecttour.in","r",stdin);
freopen("perfecttour.out","w",stdout);
scanf("%d%d",&n,&m);
m--; memset(c,-0x3f3f3f3f,sizeof(c));
for (i=1;i<=n;i++)
for (j=1;j<=m;j++){
scanf("%d",&l[i][j]);
c[j]=max(c[j],l[i][j]);}
ans=s[0]=-0x3f3f3f3f;
for (i=1;i<=m;i++){
s[i]=max(c[i],s[i-1]+c[i]);
ans=max(ans,s[i]); }
printf("%d\n",ans);
return 0;
}