#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    int col_1 = 0;
    for (int i = 0; i < n; i++) {
         cin >> a[i];
         if (a[i] == 1) {
             col_1++;
         }
    }
    if (col_1 == n) {
        if (col_1 - (n - col_1) >= k + 1) {
             cout << 0;
             return 0;
        }
        cout << 1;
        return 0;
    }
    return 0;
}
