while True:
try:
n, k = map(int, input().split())
# print(n, k)
price = map(int, input().split())
low_price = list(int(i) for i in input())
info_list = list(zip(price, low_price))
# print(info_list)
price_list = []
for info in info_list:
if info[1] == 1:
price = info[0] * 95 / 100
price_list.append(price)
else:
price = info[0]
price_list.append(price)
# 将优惠后的价格从低到高排序,这样就可以算出最多能买多少件物品
# print(sorted(price_list))
s = 0
count = 0
for price in sorted(price_list):
# 判断加上这个物品是否不超过预算,不要直接s <= k
if s + price <= k:
s += price
count += 1
else:
break
# print(price)
print(count)
except Exception as e:
break