#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int aS[N];
  int br[N];
int main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;++i)cin>>aS[i];
  for(int i=0;i<n;++i)++br[aS[i]];
  int out=0;
  if(br[2]>=k)out|=2;
  if(br[1]>=k)out|=1;
  cout<<out<<endl;
}
