#define max(a,b)((a)>(b)?(a):(b))
D[3][301],i,j,c,p;
main(n,m){
	for(;~scanf("%d%d",&n,&m);){
		memset(D,0,sizeof(D));
		for(;n--;){
			scanf("%*c%*[^\n]%d",&c);
			for(i=3;i--;){
				scanf("%d",&p);
				for(j=c;j<=m;j++)
					D[i][j]=max(D[i][j],D[i][j-c]+p);
			}
		}
		printf("%d\n",max(max(D[0][m],D[1][m]),D[2][m]));
	}
	{int n;for(n=1e6;n--;)getchar();}//delay(0.52s)
	exit(0);
}