//dp[i][j]表示前i个花瓶装前j束花的最大审美值
//dp[i][j] = max(dp[i-1][j], dp[i-1][j-1]+cost[j][i])
#include<iostream>
using namespace std;
const int INF = 1000000000;
const int N = 105;
int dp[N][N];
int cost[N][N];
int f, n;
int main()
{
while (cin >> f >> n)
{
for (int i = 1; i <= f; i++)
for (int j = 1; j <= n; j++)
cin >> cost[i][j];
for (int i = 0; i <= f; i++)
for (int j = 1; j <= n; j++)
dp[i][j] = -INF;
for (int j = 1; j <= n; j++)
dp[j][0] = 0;
dp[0][0] = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i && j <= f; j++)
dp[i][j] = max(dp[i-1][j-1]+cost[j][i], dp[i-1][j]);
cout << dp[n][f] << endl;
}
return 0;
}