import java.io.*; import java.util.*; class Main { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n=sc.nextInt(); long ww=sc.nextLong(); int p=0; long[]v=new long[n],w=new long[n]; for(int i=0;iww)continue; p++; } if (p==0){ out.println(0); out.close(); return; } int U=(int)Math.sqrt(11000000/p); int W=p*U+1; long D=Math.max(1,ww/(W-1)); int[]vt=new int[p]; for(int i=0;i=vt[i];--j){ if(dp[j]dp2[j-vt[i]]+w[i])){ dp[j]=dp[j-vt[i]]+v[i]; dp2[j]=dp2[j-vt[i]]+w[i]; } } } long ans=0; for(int i=0;i