#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
const int maxv=1e6+10;
int n,k;
int a[maxv];
int p[maxv];
vector<int>v;

void read()
{
    cin>>n>>k;
    int br1=0;
    int br2=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==1)br1++;
        if(a[i]==2)br2++;
    }
    if(br2>=k){cout<<2<<'\n';return;}
    if(br1>=k){cout<<1<<'\n';return;}
    cout<<0<<endl;
}
int main()
{
    speed();
    read();

    return 0;
}

