N, K = map(int,input().split()) S = input() must = [False] * N atari = 0 buy = 0 if N > K : for i in range(N): if S[i] == '0': if atari > 0: atari -= 1 else: buy += 1 elif S[i] == '1': if atari > 0 : atari -= 1 else: buy += 1 atari += 1 else : if atari > 0: atari -= 1 else: buy += 1 atari += 2 if i+1 == K: break else: for i in range(N): if S[i] == '0': if atari > 0: atari -= 1 else: must[i] = True elif S[i] == '1': if atari > 0 : atari -= 1 else: must[i] = True atari += 1 else : if atari > 0: atari -= 1 else: must[i] = True atari += 2 count = 0 for i in range(N): if must[i]: count += 1 l = K % N atariend = atari mustend = [False] * l for i in range(l): if S[i] == '0': if atariend > 0: atariend -= 1 else: mustend[i] = True elif S[i] == '1': if atariend > 0 : atariend -= 1 else: mustend[i] = True atariend += 1 else : if atariend > 0: atariend -= 1 else: mustend[i] = True atariend += 2 countend = 0 for i in range(l): if mustend[i]: countend += 1 if atari >= count : buy = count else: if l == 0: buy = count + (count - atari) * (K // N - 1) else : buy = count + (count - atari) * (K // N - 1) + countend print(buy)