#include<bits/stdc++.h>usingnamespace std;int M, N;voidslove(){
vector<int>weight(M);
vector<int>value(M);for(int i =0; i < M; i++) cin >> weight[i];for(int i =0; i < M; i++) cin >> value[i];// 定义dp数组,dp数组初始化
vector<int>dp(N +1,0);// 遍历推导dp数组for(int i =0; i < M; i++){// 物品for(int j = N; j >= weight[i]; j--){// 背包
dp[j]=max(dp[j], dp[j - weight[i]]+ value[i]);}}
cout << dp[N]<<'\n';}intmain(){while(cin >> M >> N)slove();return0;}