#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int br = 0;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        if(a == 1) br++;
    }
    if(br >= k) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}
