#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define vii vector <int>
#define endl '\n'
const int inf = 1e18;
const int N = 2e5+5;
inline void test_case() {
    int n, k;
    cin >> n >> k;
    int a[n];
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i]) cnt++;
    }
    if (cnt >= k) {
        cout << 1 << endl;
    } else cout << 0 << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) test_case();
}