n, k = map(int, input().split()) A = list(map(int, input().split())) k -= 1 if A[k] == 0: print(0) exit() l, r = k - 1, k + 1 while l >= 0: if A[l] <= 1: break l -= 1 if l == -1: l += 1 while r < n: if A[r] <= 1: break r += 1 if r == n: r -= 1 print(sum(A[l:r + 1]))