n, k = map(int,input().split())
jia = list(map(int, input().split()))
b = input()
hao = []
for i in b:
    hao.append(int(i))
zu = list(zip(jia,hao))
zhong = []
for x, y in zu:
    if y == 1:
        x = x * 0.95
    zhong.append(x)
zhong.sort()
g = 0
s = 0
while s < k:
    s += zhong[g]
    g += 1
if s == k:
    print(g)
else:
    print(g-1)