#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair <ll, ll>
#define ret return
#define pb push_back
#define all(x) x.begin(), x.end()
#define fr first
#define sc second

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n,k,c = 0;
    bool tst2 = true;
    cin >> n >> k;
    vector <int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i] > 1) tst2 = false;
        else if(a[i] == 1) c++;
    }
    if(tst2) {
        if(c >= k) cout << 1;
        else cout << 0;
    }
}
