#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN=51;
const int MAXM=502;
const int oo=1000000000;
int n,m,i,j,k,l,f[MAXN][MAXN][MAXM],ans=0,sum[MAXN][MAXN],lim=1;
int main()
{
freopen("skill.in","r",stdin);
freopen("skill.out","w",stdout);
scanf("%d%d",&n,&m);
for (i=1;i<=n;i++)
for (j=1;j<=n-i+1;j++)
{
scanf("%d",&k);
sum[j][i]=sum[j][i-1]+k;
}
for (i=0;i<MAXN;i++)
for (j=0;j<MAXN;j++)
for (k=1;k<MAXM;k++)
f[i][j][k]=-oo;
f[n][1][1]=sum[n][1];
for (i=n-1;i>=1;i--)
{
lim+=n-i+1;
for (j=0;j<=n-i+1;j++)
for (k=(j+1)*j/2;k<=min(lim,m);k++)
for (l=j-1;l<=n-i;l++)
{
f[i][j][k]=max(f[i][j][k],f[i+1][l][k-j]+sum[i][j]);
if (f[i][j][k]>ans) ans=f[i][j][k];
}
}
printf("%d\n",ans);
return 0;
}