#include <iostream>
#define int long long
using namespace std;
int v[1000005];
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        if(v[i]==1) cnt++;
    }
    if(cnt>=k) cout<<1;
    else cout<<0;
    return 0;
}
