n,k=map(int,input().split())
l1=list(map(int,input().split()))
l2=list(map(int,input()))
h=[]
t=0
c=0
for i in range(n):
    if l2[i]==1:
        h.append((l1[i])*0.95)
    else:
        h.append(l1[i])
h.sort()
for j in h:  
    t+=j
    if t<=k:
        c+=1
    else:
        break

print(c)