#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char** argv) {
	int n,k,i,j,brr;
	cin>>n;
	cin>>k;
	int a[n],br[n];
	brr=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for (i=0;i<n;i++){
		br[i]=1;
		for(j=i+1;j<n;j++){
			if(a[i]==a[j])
			{
				br[i]++;
			}
		}
	}
	for(i=0;i<n;i++){
		if(br[i]>=k)
		{
			brr++;
	
		}
	}
	cout<<brr<<endl;
	for(i=0;i<n;i++){
		if(br[i]>=k){
			cout<<a[i]<<" ";
		}
	}
	return 0;
}