N,K=map(int,input().split()) A=list(map(int,input().split())) K-=1 if A[K]==0: print(0) exit() l=0 r=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])