import java.util.Arrays;
import java.util.Scanner;
public class Main {
private final static int N = 999;
public static int SumValue = 0;
public static int SumWeight = 0;
public static int OptimalValue = 0;
public static int OptimalSolution[] = new int[N];
public static int w[] = new int[N];
public static int v[] = new int[N];
public static int x[] = new int[N];
public static int n;
public static int c;
public static void backTracking(int t) {
if(t>n) {
if(SumValue > OptimalValue) {
OptimalValue = SumValue;
for(int i=1;i<=n;i++)
OptimalSolution[i]=x[i];
}
}else {
for(int i=0;i<=1;i++) {
x[t]=i;
if(i==0) {
backTracking(t+1);
}else {
if(SumValue+w[t]<=c) {
SumWeight += w[t];
SumValue += v[t];
backTracking(t+1);
SumValue -= v[t];
SumWeight -= w[t];
}
}
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
Arrays.fill(w, 0);
Arrays.fill(v, 0);
Arrays.fill(x, 0);
c = sc.nextInt();
for(int i=1;i<=n;i++)
{
int temp = sc.nextInt();
w[i]=temp;
temp = sc.nextInt();
v[i]=temp;
}
backTracking(1);
System.out.print(OptimalValue);
}
}