#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 pair get(pair x,pair y){ if(x.first==y.first){ x.second += y.second; return x; } if(x.first>y.first)return x; return y; } pair e(){ return make_pair(0,0); } int main(){ int N,K; cin>>N>>K; vector c(N),d(N); rep(i,N)cin>>c[i]; rep(i,N)cin>>d[i]; vector> dp(K+1,e()); dp[0] = make_pair(0,1); rep(i,K){ rep(j,N){ if(i+c[j]<=K){ auto v = dp[i]; v.first += d[j]; dp[i+c[j]] = get(dp[i+c[j]],v); } } } pair ans = e(); //ans.second = 1; rep(i,K+1)ans = get(ans,dp[i]); cout<