#include<cstdio>
#include<iostream>
int i,j,k,n,m,l,a[52][52],f[52][502][52],max=0,x,s[52][52],sum[52];
int main(){
scanf("%d%d",&n,&m);
for (i=1;i<=n;i++)
for (j=1;j<=n-i+1;j++){
scanf("%d",&a[i][j]);
s[j][i]=s[j][i-1]+a[i][j];
}
for (i=1;i<=n;i++)
sum[i]=sum[i-1]+i;
f[n+1][0][0]=0;
for (i=n;i>=1;i--)
for (j=0;j<=n-i+1;j++)
for (k=j-1;k<=n-i;k++)
for (l=j+sum[k];l<=m;l++)
if (f[i][l][j]<f[i+1][l-j][k]+s[i][j]) f[i][l][j]=f[i+1][l-j][k]+s[i][j];
for (i=1;i<=n;i++)
for (j=0;j<=n-i+1;j++)
if(f[i][m][j]>max)
max=f[i][m][j];
printf("%d\n",max);
}