#include <iostream>
#include <string.h>
using namespace std;
int a[101], c[101];
int f[100005], num[100005];
int main()
{
int n, m;
memset(f,0,sizeof(f));
while(scanf("%d %d", &n, &m), n + m)
{
int i, j, inc, ans, flag;
for(i = 0; i < n; i ++)
scanf("%d", &a[i]);
for(i = 0; i < n; i ++)
scanf("%d", &c[i]);
f[0] = 1;
ans = 0;
for(i = 0; i < n; i ++)
{
for(j = a[i]; j <= m; j ++)
if(!f[j] && f[j-a[i]] && num[j-a[i]]<c[i])
{
f[j] = 1;
num[j] = num[j - a[i]] + 1;
ans ++;
}
for(j = 0; j <= m; j ++) num[j] = 0;
}
for(i = 0; i <= m; i ++) f[i] = 0;
printf("%d\n",ans);
}
}