#include <iostream>

#define MAXN 1000000

using namespace std;

int v[MAXN];

int main() {
    int n, k, f, i;

    cin >> n >> k;
    f = 0;
    for (i = 0; i < n; i++) {
        cin >> v[i];
        f += (v[i] == 1);
    }

    if (f >= k) {
        cout << 1;
    } else {
        cout << 0;
    }

    return 0;
}
