#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <iterator>
#include <iostream>
#include <list>
using namespace std;
int main()
{
  long n,k;
  long br=0;
  scanf("%ld%ld",&n,&k);
  long a[n];
  list<long> b;
  for(long i=0; i<n; i++)
   scanf("%ld",&a[i]);
  set<long> s(a, a+n);
  multiset<long> m(a,a+n);
  for (auto it = s.begin(); it != s.end(); it++)
   if(m.count(*it)>=k){
    b.push_back(*it);
    br=br+1;
   }
   printf("%ld",br);
   printf("\n");
   for (auto it = b.begin(); it != b.end(); it++)
    printf("%ld ",*it);
}