#include <bits/stdc++.h>
using namespace std;

#define ll long long

const ll MAXN = 1e6;

ll N, K, one = 0;
vector<ll> a(MAXN);

int main() {
    cin >> N >> K;
    a.resize(N);

    
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] == 1) {
            one++;
        }
    }

    if (K <= one) {
        cout << 1;
    }
    else {
        cout << 0;
    }
}