n, k = list(map(int, input().split())) a = list(map(int, input().split())) l_sum = 0 r_sum = 0 for i in range(k, n): if a[i] == 0: break elif a[i] == 1: r_sum += 1 break else: r_sum += a[i] for i in range(k - 2, -1, -1): if a[i] == 0: break elif a[i] == 1: l_sum += 1 break else: l_sum += a[i] ans = a[k - 1] if a[k - 1] == 1: ans += max(l_sum, r_sum) if a[k - 1] > 1: ans += l_sum + r_sum print(ans)