n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input()))
for i in range(n):
    if b[i] == 1:
        a[i]*=0.95
a.sort()# 升序排序,优先买便宜的,才能买最多
count = 0
price = 0
j = 0
# 1. 循环条件增加j < n(避免索引越界)
# 2. 先加价格,再判断是否超预算;未超才计数

while j<n and price+a[j]<=k:
    price += a[j]
    count+=1
    j+=1

print(count)