import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,K=MI() K-=1 A=LI() if A[K]==0: print(0) exit() if min(A)>=2: print(sum(A)) else: ans=A[K] for i in range(K+1,N): if A[i]==1: ans+=1 break elif A[i]==0: break else: ans+=A[i] for i in range(K-1,-1,-1): if A[i]==1: ans+=1 break elif A[i]==0: break else: ans+=A[i] print(ans) main()