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

const int maxn = 1e6 + 1;
int nc[maxn];

int main () {
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/
    int n, k, r = -1, hval = 0, br1 = 0, ans;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> nc[i];
        if(nc[i] == 1) br1++;
    }
    if(br1 < k) ans = 0;
    else ans = 1;
    cout << ans;
   /* vector <int> val;
    while(r + 1 < n && (hval | nc[r + 1]) != hval) {
        r++;
        cout << r << ' ';
        int num = (hval | nc[r]);
        if(num == hval) {
            cout << r << ':' << hval << '\n' << '-' << '\n';
            val.push_back(hval);
            hval = 0;
            continue;
        }
        cout << hval << "->" << num << '\n';
        hval = num;
    }
    ans = val[0];
    for(int i = 1; i < val.size(); i++) {
        ans = ans & val[i];
    }
    cout << ans;
    return 0;*/
}
