N, K = [int(i) for i in input().split()] S = list(input()) # 一箱目 atari = 0 buy = 0 first_box_cnt = [] for ice in S: if atari > 0: atari -= 1 else: buy += 1 if ice == '1': atari += 1 elif ice == '2': atari += 2 first_box_cnt.append(buy) # 二箱目 buy = 0 second_box_cnt = [] for ice in S: if atari > 0: atari -= 1 else: buy += 1 if ice == '1': atari += 1 elif ice == '2': atari += 2 second_box_cnt.append(buy) # Kの大きさで場合分け if K <= N: print(first_box_cnt[K-1]) elif N < K: box_cnt = K // N res = first_box_cnt[-1] res += second_box_cnt[-1] * (box_cnt - 1) if K % N != 0: res += second_box_cnt[(K % N) - 1] print(res)