#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for(int &num : v)cin >> num;

    int countOne = 0;
    for(int &num : v)if(num)countOne++;

    if(countOne < k){cout << 0; return 0;}
    cout << 1;
}
