#include <iostream>
const int NMAX=1000005;

using namespace std;

int v[NMAX];

///facem subtask 2

int main()
{
    int n,k,nr1=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        nr1+=(v[i]==1);
    }
    cout<<(nr1>=k);
    return 0;
}
