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 U=64; int W=5001*U; long D=Math.max(1,ww/U/n); long[]v=new long[n],w=new long[n]; int[]vt=new int[n]; for(int i=0;iww?W:(int)((w[i]+D-1)/D); } long[]dp=new long[W]; Arrays.fill(dp,0); for(int i=0;i=vt[i];--j) dp[j]=Math.max(dp[j],dp[j-vt[i]]+v[i]); } long ans=0; for(int i=0;i