N, K = map(int, input().split()) A = list(map(int, input().split())) left, right = 0, N K -= 1 for i in range(K - 1, -1, -1): if A[i] <= 1: left = i break for i in range(K + 1, N): if A[i] <= 1: right = i + 1 break L, R = 0, 0 for i in range(left, K): L += A[i] for i in range(K + 1, right): R += A[i] if A[K] == 0: print(0) elif A[K] == 1: print(max(L, R) + 1) else: print(L + R + A[K])