N,K = map(int,input().split()) lsA = list(map(int,input().split())) K -= 1 if lsA[K] == 0: print(0) elif lsA[K] == 1: a1 = 0 ind = K+1 while ind < N: if lsA[ind] == 0: break elif lsA[ind] == 1: a1 += 1 break else: a1 += lsA[ind] ind += 1 a2 = 0 ind = K-1 while 0 <= ind: if lsA[ind] == 0: break elif lsA[ind] == 1: a2 += 1 break else: a2 += lsA[ind] ind -= 1 print(max(a1,a2)) else: a1 = 0 ind = K+1 while ind < N: if lsA[ind] == 0: break elif lsA[ind] == 1: a1 += 1 break else: a1 += lsA[ind] ind += 1 a2 = 0 ind = K-1 while 0 <= ind: if lsA[ind] == 0: break elif lsA[ind] == 1: a2 += 1 break else: a2 += lsA[ind] ind -= 1 print(a1+a2+lsA[K])