N, K = list(map(int, input().split())) A_list = list(map(int, input().split())) if A_list[K-1] == 0: print(0) else: left = 0 right = 0 position = K-1 while True: # 左 position -= 1 if position >= 0: if A_list[position] <= 1: left += A_list[position] break else: left += A_list[position] else: break position = K-1 while True: # 右 position += 1 if position <= N-1: if A_list[position] <= 1: right += A_list[position] break else: right += A_list[position] else: break if A_list[K-1] == 1: print(max([left, right])+1) else: print(left+right+A_list[K-1])