//简单的dp
#include<cstdio>
#define Max(a,b) ((a)>(b)?(a):(b))
int d[];
int main()
{
int i,j,n,m,x,t,te;
scanf("%d%d",&n,&m);
for(i=; i<=n; ++i)
{
for(j=; j<=m; ++j)
{
scanf("%d",&x);
d[j] = x + Max(d[j],d[j-]);
}
}
printf("%d\n",d[m]);
return ;
}
//简单的dp
#include<cstdio>
#define Max(a,b) ((a)>(b)?(a):(b))
int d[];
int main()
{
int i,j,n,m,x,t,te;
scanf("%d%d",&n,&m);
for(i=; i<=n; ++i)
{
for(j=; j<=m; ++j)
{
scanf("%d",&x);
d[j] = x + Max(d[j],d[j-]);
}
}
printf("%d\n",d[m]);
return ;
}