#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long prebroji(long long a[], long long n, long long j){
    long long br = 0;
    long long i;
    for(i = 0; i < n; i++){
        if(j == a[i])
        br++;}
    return br;
    }
int main()
{

    long long n, i, k, j;
    long long p = 0, l = 0;
    cin >> n >> k;
    long long a[n], b[p];
    for(i = 0; i < n; i++)
        cin >> a[i];
    long long br[2*n + 1];


    if(k == 1){
        cout << n << endl;
        for(i = 0; i < n; i++)
        cout << a[i] << " ";}

    else{
    for(j = -n; j <= n; j++){
        br[j] = prebroji(a, n, j);
        if(br[j] >= k){
        b[l++] = j;

        p++;
        }

        }}

    cout << p << endl;
    for(l = 0; l < p; l++)
        cout << b[l] << " ";




    return 0;
}