#include <bits/stdc++.h>
using namespace std;
int st(int a , int s)
{
    if(s == 0) return 1;
    int starter = a;
    for(int i = 1;i < s;i++)
    {
        a *= starter;
    }
    return a;
}
signed main()
{
    int n , k;cin >> n >> k;
    vector <vector <int>> v(n);
    int br = 0;
    for(int i = 0;i < n;i++)
    {
        int a;cin >> a;
        if(a == 1)br++;
        if(a != 0&&a != 1)return 0;
        /*int j = 30;
        while(j >= 0)
        {
            int c = st(2 , j);
            if(c <= a)
            {
                a -= c;
                v[i].push_back(1);
            }
            else
            {
                v[i].push_back(0);
            }
            j--;
        }*/
    }
    if(br <= k) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < v[i].size();j++)
        {
            cout << v[i][j];
        }
        cout << " ";
    }

}
/*
7 3
2 1 4 3 2 2 5
*/
