#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N>>M; FOR(i,N) cin>>A[i]; FOR(i,N) cin>>K[i], tot += K[i]*A[i]; if(tot=0) can[i] = min(can[i], can[i-A[x]]+1); if(M>=i && i==ne[x]) ret=min(ret,can[i]+(M-i)/A[x]), ne[x] += A[x]; } } if(ret>=1LL<<60) ret=-1; cout<