#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAX_N = 1e6;
int n, k, a[MAX_N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> k;
    int cnt1 = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i] == 1) ++cnt1;
    }
    cout << (cnt1 >= k) << endl;
    return 0;
}
