#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int solve( const int N, VI costs, VI p )
{
	VI dp( N + 1, 0 );

	REP( i, 0, costs.size() )
	{
		REP( j, 0, N + 1 )
		{
			if ( 0 <= j - costs[i] )
			{
				dp[j] = max( dp[j], dp[ j - costs[i] ] + p[i] );
			}
		}
	}

	return *max_element( ALL( dp ) );
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	int n, m;

	while ( cin >> n >> m )
	{
		VI c( n ), v( n ), d( n ), l( n );

		REP( i, 0, n )
		{
			string name;

			cin.ignore( 1 );
			getline( cin, name );

			cin >> c[i] >> v[i] >> d[i] >> l[i];
		}

		int res1 = solve( m, c, v );
		int res2 = solve( m, c, d );
		int res3 = solve( m, c, l );

		cout << max( res1, max( res2, res3 ) ) << endl;
	}

	return 0;
}