
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <assert.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'

using namespace std;
using namespace __gnu_pbds;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n,k;
long long dp[3000][3000];
long long a[3000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    for(int i = 1; i <= n; i++) {cin >> a[i];}
    int br=0;
    for(int i = 1; i <= n; i++) if(a[i]==0) br++;
    if(br==n) cout << 0;
    else if(k<=n-br) cout<<1;
    else cout<<0;
}
/*
7 5
1 0 0 1 1 1 1
*/
