#include <iostream>
using namespace std;

int main()
{

int n, k;
cin>> n>> k;
int i=0, j=0;
int pogodak[n];


for(i=0; i<n; i++)
{
    cin>>pogodak[i];
}
int brojac = 0;
int d=0;
int pogodak2[n];
int pogodak3[n];
for(i=0;i<n;i++)
{
    pogodak2[i]=pogodak[i];
    pogodak3[i]=pogodak[i];
}
for(i=0; i<n; i++)
{
    for(j=0;j<n;j++)
    {
        if(pogodak[i]==pogodak2[j])
       {
      
         brojac= brojac + 1;
         pogodak2[j]=n+1;
     }
    }
    //brojac= brojac-1;
       if(brojac>(k-1))
    {
    
            d=d+1; 
        
    }
    
    brojac=0;
}
cout<<d<<endl;
for(i=0; i<n; i++)
{
    for(j=0;j<n;j++)
    {
        if(pogodak[i]==pogodak3[j])
       {
      
         brojac= brojac + 1;
         pogodak3[j]=n+1;
     }
    }
    //brojac= brojac-1;
       if(brojac>(k-1))
    {
    
        if(pogodak[i]<(n+1))
        {
            cout<<pogodak[i]<<" ";
        }
        
    }
    
    brojac=0;
}

}