#include <iostream>

using namespace std;


int niz[2000001];
int nula = 1000000;
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, k;

  cin >> n >> k;

  int counter = 0;
  int m;

  for (int i = nula - n; i < nula + n + 1; ++i){
    niz[i] = 0;
  }
  for (int i = 0; i < n; ++i){
    cin >> m;
    m += nula;
    ++niz[m];
    if (niz[m] == k){
      counter++;
    }
  }

  k -= 1;
  cout << counter << endl;
  for (int i = nula - n; i < nula + n + 1; ++i){
    if (niz[i] > k){
      cout << i - nula << " ";
    }
  }
  
  return 0;
}