#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  K--;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  if(A[K] == 0){
    cout << 0 << endl;
    return 0;
  }
  ll sum_l=0;
  for(int i=K+1; i<N; i++){
    sum_l += A[i];
    if(A[i] < 2){
      break;
    }
  }
  ll sum_r=0;
  for(int i=K-1; i>=0; i--){
    sum_r += A[i];
    if(A[i] < 2){
      break;
    }
  }
  if(A[K] == 1){
    cout << max(sum_l,sum_r) + 1 << endl;
  }else{
    cout << sum_l + sum_r + A[K] << endl;
  }
  return 0;
}