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

#define ll long long
#define pb push_back
#define ff first
#define sc second
#define pii pair<int, int>

const int maxN = 1e6 + 25;
const int inf = 1e9;
const ll big_inf = 1e18;
const int mod = 1e9 + 7;

int a[maxN];
int n, k;
int ans;

void solve() {
    cin >> n >> k;
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[i])cnt++;
    }
    if(cnt < k) {
         cout << 0;
    }
    else cout << 1;
}

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

    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
        cout << '\n';
    }
}