# Include <cstring> # include <string> # include <cstdio> # include <cmath> # include <algorithm> # include <vector> # include <queue> # include <map> # define INF 0x3f3f3f # define ll _ int64using namespace STD; int n, m, DP [100010], a [100010], C [1010]; void pack01 (INT cost, int W) {for (INT I = m; I >= cost; I --) DP [I] = max (DP [I-cost] + W, DP [I]);} void packall (INT cost, int W) {for (INT I = cost; I <= m; I ++) DP [I] = max (DP [I-cost] + W, DP [I]);} void multipack (INT cost, int W, int CNT) {If (Cost * CNT> = m) // The volume multiplied by the quantity is greater than the total volume, which means it cannot be fully loaded, it is equivalent to infinite parts. packall (cost, W) is used as the complete backpack. Else // can be used up. 01 is used as the backpack {int I = 1; while (I <CNT) // binary optimization {pack01 (Cost * I, w * I); CNT-= I; I + = I;} pack01 (Cost * CNT, w * CNT );}} int main () {int I; while (scanf ("% d", & N, & M) & (N | M )) {for (I = 0; I <n; I ++) scanf ("% d", & A [I]); for (I = 0; I <N; I ++) scanf ("% d", & C [I]); memset (DP, 0, sizeof DP); for (I = 0; I <N; I ++) multipack (A [I], a [I], C [I]); int ans = 0; for (I = 1; I <= m; I ++) if (DP [I] = I) ans ++; printf ("% d \ n", ANS);} return 0 ;}