/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
  

   long long  n,k;
 long long polje,indeks,count;
  int pomocni[10000000];
  int niz[10000000];
  
  
  cin>>n>>k;
  count=0;


  
  for(int l=1;l<=2*n;l++) //postavlja sve vrednosti niza na 0
  pomocni[l]=0;

  for(int i=1;i<=n;i++) //unosi pogotke
  {
     cin>>polje;       //lazni indeks
     indeks=polje+n; //pravi indeks
     niz[indeks]=polje;

     pomocni[indeks]=pomocni[indeks]+1;
     
     if(pomocni[indeks]==k) 
     {
         count++;
         
     }

  }

  cout<<count<<"\n";

for(int j=0;j<2*n;j++)
if(pomocni[j]>=k)
cout<<niz[j]<<" ";

}