#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
inline void smax(int &a, int b){a = max(a,b);}
int ternary_search(int l,int r, vector<int> &dp, int a, int b, int wt){
int ans = 0;
auto cal = [&](int mid){
if(wt-mid*a < 0) return 0LL;
return dp[wt-mid*a]+mid*b;
};
while(r - l > 5){
int mid = l + (r-l)/2;
if(cal(mid) > cal(mid+1)) r = mid;
else l = mid;
}
// rep(i,l,r) cout << cal(i) << " " ;nl;
rep(i,l,r) smax(ans, cal(i));
return ans;
}
void solve(){
int n,x; cin >> n >> x;
vi aa(n),bb(n),cc(n);
fr(i,n) cin >> aa[i];
fr(i,n) cin >> bb[i];
fr(i,n) cin >> cc[i];
vi dp(2*x+5);
fr(i,n){
int a = aa[i], b = bb[i] , c = cc[i];
vi tempdp = dp;
for(int wt=0;wt<=x+5;wt++){
// for(int j=1; j<=c; j++){
// if(wt - j * a < 0) break;
// smax(tempdp[wt],dp[wt-j*a]+j*b);
// }
int l = 1, r = min(wt/a + 1,c);
if(l > r) continue;
int mx = ternary_search(l,r,dp,a,b,wt);
smax(tempdp[wt], mx);
}
swap(dp,tempdp);
// fr(i,x+1) cout << dp[i] << " ";nl;
}
cout << dp[x];
}
int32_t main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tst=1; while(tst--){
solve();
}
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZGJnKHZhcikgY291dDw8I3Zhcjw8Ij0iPDx2YXI8PCIgIgojZGVmaW5lIG5sIGNvdXQ8PCJcbiIKI2RlZmluZSBmcihpLG4pIGZvcihpbnQgaT0wO2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