#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 300
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

static int n;
static int m;
static int c[ N ];
static int v[ N ];
static int d[ N ];
static int l[ N ];
const static int *p;

static int k_operafan[ N + 1 ][ N ];

int
dpFSA (
  const int m,
  const int k
  )
{
  int i;

  if ( k >= n ) return ( 0 );

  if ( k_operafan[ m ][ k ] != -1 ) ;
  else
  {
    int res = 0;

    for ( i = 0; m - c[ k ] * i >= 0; ++i )
      res = MAX( res, dpFSA ( m - c[ k ] * i, k + 1 ) + p[ k ] * i );

    k_operafan[ m ][ k ] = res;
  }

  return ( k_operafan[ m ][ k ] );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  char buf[ BUFSIZ ];
  int i;

  for ( ; ; )
  {
    int res = 0;

    if ( fgets ( buf, BUFSIZ, stdin ) == NULL )
      break ;
    sscanf ( buf, "%d%d", &n, &m );
    for ( i = 0; i < n; ++i )
    {
      fgets ( buf, BUFSIZ, stdin );
      fgets ( buf, BUFSIZ, stdin );
      sscanf ( buf, "%d%d%d%d", &c[ i ], &v[ i ], &d[ i ], &l[ i ] );
    }

    p = v;
    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    res = MAX( res, dpFSA ( m, 0 ) );
    p = d;
    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    res = MAX( res, dpFSA ( m, 0 ) );
    p = l;
    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    res = MAX( res, dpFSA ( m, 0 ) );

    printf ( "%d\n", res );
  }

  return ( EXIT_SUCCESS );
}