#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);


    int K , N;

    cin >> N  >> K ;

    int arr[N];
    string brojevi;

    for(int i = 0 ; i< N ; i++)
    {
        cin >> arr[i];
    }

    sort(arr , arr+N);

    int value = arr[0];
    int counter = 1;
    int swwitch = 0;
    int counter_numbers = 0;
    for ( int i = 1 ; i < N ; i++)
    {
        if ( value == arr[i])
        {
            counter++;
            if( counter >= K)
            {
                arrX[counter_numbers]= value;
                swwitch = 1;

            }
        } else{
            if(swwitch == 1)
            {
                counter_numbers++;
                swwitch = 0;
            };
            counter = 1;
            value = arr[i];
        }
    }
    if ( counter < K)
    {
        counter_numbers-=1;
    }

    cout << counter_numbers+1 << endl;
    for(int i = 0 ; i <= counter_numbers ; i++)
    {
        cout << arrX[i] << " ";
    }
}