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

#define FALSE 0
#define TRUE  1

#define MIN(a, b) ((a)<(b) ?  (a) : (b))
#define MAX(a, b) ((a)>(b) ?  (a) : (b))
#define ABS(a) 	((a)< 0  ? -(a) : (a))
#define IMPAR(a)	((a)&1)
#define CTOI(a)	((a) - '0')
#define ITOC(a)	((a) + '0')

#define MAX_TAM	100

typedef struct {int peso, valor;} TItem;
TItem itens[MAX_TAM];
	
// Variaveis do knapsack
int C[MAX_TAM + 1][10001], V[MAX_TAM + 1][10001];

int knapsack01(int, int);

int main()
{	int T, L, l;
	char possivel;
	
	while (scanf("%d %d", &L, &T) != EOF)
	{	for (l = 0, possivel = FALSE; l < L; l++)
		{	scanf("%d %d", &itens[l].valor, &itens[l].peso);
			if (itens[l].peso <= T )
				possivel = TRUE;
		}
/*		
		for (l = 0; l < L; l++)
			printf("%d %d\n", itens[l].valor, itens[l].peso);
		printf("\n\n");
*/		
		if (!possivel)
			puts("-1");
		else
			printf("%d\n", knapsack01(L, T));
/*			
			for (xi = 0; xi <= L; xi++)
			{	for (xw = 0; xw <= MW; xw++)
					printf("%2d ", C[xi][xw]);
				printf("\n");
			}
			printf("*************************\n");
*/
	}
	
	return 0;
}

int knapsack01(int qtItens, int tamMochila)
{	int xi, xw, MW;

 //The solution can be found in C[N][W];
	MW = tamMochila;			// Tamanho da mochila
	
	for (xi = 0; xi <= qtItens; xi++)
		C[xi][0] = V[xi][0] = 0;
			
	for (xw = 0; xw <= MW; xw++) 
		C[0][xw] = V[0][xw] = 0;
			
	for (xi = 1; xi <= qtItens; xi++)
		for (xw = 1; xw <= MW; xw++)
		{	if (itens[xi - 1].peso > xw)
			{	C[xi][xw] = C[xi - 1][xw];
				V[xi][xw] = V[xi - 1][xw];
			}
			else
				if (C[xi - 1][xw] > C[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].valor)
				{	C[xi][xw] = C[xi - 1][xw];
					V[xi][xw] = V[xi - 1][xw];
				}
				else
				{	C[xi][xw] = C[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].valor;
					V[xi][xw] = V[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].peso;
				}
		}

	return C[qtItens][MW];
}