N,K=map(int, input().split()) A=list(map(int, input().split())) lcnt,rcnt=0,0 K-=1 if A[K]==0: print(0) exit() for i in range(K): if A[K-1-i]==0: break elif A[K-1-i]==1: lcnt+=1 break else: lcnt+=A[K-1-i] for i in range(N-K-1): if A[K+1+i]==0: break elif A[K+1+i]==1: rcnt+=1 break else: rcnt+=A[K+1+i] if A[K]==1: print(max(rcnt,lcnt)+1) else: print(rcnt+lcnt+A[K])