#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ldb long double
#define mt make_tuple
const int N=1000050;
int n,k,a[N],cnt[N*2];
vector<int> ans;
void input()
{
	scanf("%i %i",&n,&k);
	for(int i=1;i<=n;i++) scanf("%i",&a[i]);
}
void output()
{
	printf("%i\n",ans.size());
	for(int i:ans) printf("%i ",i);
	printf("\n");
}
void Solve()
{
	for(int i=-n;i<=n;i++) cnt[N+i]=0;
	for(int i=1;i<=n;i++) cnt[N+a[i]]++;
	ans.clear();
	for(int i=-n;i<=n;i++) if(cnt[N+i]>=k) ans.pb(i);
}
void Run()
{
	input();
	Solve();
	output();
}
vector<int> bans;
void BruteForce()
{
	bans.clear();
	for(int i=-n;i<=n;i++)
	{
		int c=0;
		for(int j=1;j<=n;j++) if(a[j]==i) c++;
		if(c>=k) bans.pb(i);
	}
}
void MakeTestCase()
{
	n=rand()%1000000+1;
	k=rand()%n+1;
	for(int i=1;i<=n;i++) a[i]=rand()%(n*2+1)-n;
}
bool Compare()
{
	return ans==bans;
}
void Print()
{
	printf("%i %i\n",n,k);
	for(int i=1;i<=n;i++) printf("%i ",a[i]);printf("\n");
	printf("Solve:\n");for(int i:ans) printf("%i ",i);printf("\n");
	printf("Brute:\n");for(int i:bans) printf("%i ",i);printf("\n");
}
double GetTime(){ return (ldb)clock()/CLOCKS_PER_SEC;}
double s_time,e_time,d_time;
void Start(){ s_time=GetTime();}
void Stop(){ e_time=GetTime();d_time=e_time-s_time;}
void Test()
{
	srand(time(0));
	cout<<fixed<<setprecision(4);
	int work=100000;
	double max_time=0;
	bool speed_only=1;
	for(int i=1;i<=work;i++)
	{
		MakeTestCase();
		if(!speed_only) BruteForce();
		Start();
		Solve();
		Stop();
		if(!speed_only && !Compare())
		{
			Print();
			return;
		}
		max_time=max(max_time,d_time);
		cout<<i<<":OK, max time so far="<<max_time<<"\n";
	}
	cout<<":D\n";
}
int main()
{
	Run();
	return 0;
}