#include<bits/stdc++.h>
using namespace std;
#define N 1000009
int n , k;
vector<int> v;
int mx = 0;
int a[N];

void solve(){
    cin >> n >> k;
    int co = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        co += (a[i] == 1);
    }
    cout << (co >= k ? 1 : 0) << endl;
}

int main(){
    solve();
}