#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>niz(n);
    int jedinice=0;
    for(int i=0;i<n;i++){
        cin>>niz[i];
        if(niz[i]==1) jedinice++;
    }
    if(jedinice>=k)cout<<1<<endl;
    else cout<<0<<endl;

}