import sys input = sys.stdin.readline N, K = map(int, input().split()) Alist = list(map(int, input().split())) left, right = 0, 0 for i in reversed(range(K-1)): A = Alist[i] if A == 0: break if A == 1: left += 1 break else: left += A for i in range(K, N): A = Alist[i] if A == 0: break if A == 1: right += 1 break else: right += A now = Alist[K-1] if now == 0: print(0) if now == 1: print(max(left, right)+1) if now >= 2: print(left+right+K)