#include <iostream>
#include <cstdio>
using namespace std;
int maxint(int a,int b)
{
if (a>b)
return(a);
return(b);
}
int a[110][110],f[110][110];
int main(void)
{
freopen("machinea.in","r",stdin);
freopen("machinea.out","w",stdout);
int i,j,k,m,n;
cin>>m>>n;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
cin>>a[i][j];
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
for (k=0;k<=j;k++)
f[i][j]=max(f[i][j],f[i-1][j-k]+a[i][k]);
cout<<f[n][m]<<endl;
return(0);
}