#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back




int main(){
	int n,k;
	cin >> n >> k;
	map<int,int> mp;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		mp[a]++;
		if(mp[a]>=k) s.insert(a);
	}
	cout<<s.size()<<"\n";
	for(auto x:s)
	cout<<x<<" ";
}