N,K = map(int,input().split()) S = list(input()) temp = 0 for i in range(N): if S[i]=='2': S[i]='1' temp+=1 elif S[i]=='0' and temp>0: S[i]='1' temp-=1 if K==1: print(1) elif N==1: if S[0]=='0': print(K) else: print(1) elif N0: S[i]='1' temp-=1 K-=N+1 ans+=(K//N)*S.count('0') if K%N>0: ans+=S[:K%N].count('0') print(ans) else: print(1+S[:K-1].count('0'))