n,k = map(int,input().split()) A = list(map(int,input().split())) k -= 1 if A[k] == 0: print(0) else: l,r = 0,0 for i in range(k-1, -1, -1): l += A[i] if A[i] <= 1: break for i in range(k+1, n): r += A[i] if A[i] <= 1: break if A[k]==1: print(max(l, r) + 1) else: print(l + r + A[k])