#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main()
{
    vector<int> v;
    int n,k,br=1,rez=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
         {

            if(a[i]!=1000001)
            {
                if(a[i]==a[j])
                {
                    br++;
                    a[j] = 1000001;
                }
            }
         }
        if(br>=k) {
            rez++;
            v.push_back(a[i]);
        }
        br=1;
    }
    cout<<rez<<endl;
    for (int i = 0; i < rez; i++)
        cout << v.at(i) << " ";
    return 0;
}