#include <iostream>
const int NMAX=1000005;

using namespace std;

int v[NMAX];

///facem subtask 2

int main()
{
    int n,k,bit1=0,bit2=0,ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        bit1+=(v[i]==1);
        bit2+=(v[i]==2);
    }
    if(bit1>=k) ans+=1;
    if(bit2>=k) ans+=1;
    cout<<ans<<endl;
    return 0;
}
