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