#include <iostream>
#include <vector>
using namespace std;

#define pb push_back
#define loop(i,a,b) for(int i = a; i < b; i++)
#define loop_u(i,a,b) for(unsigned int i = a; i < b; i++)

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll n, k;
	cin >> n >> k;

	ll arr[2*n+1];
	ll br_zamena = 0;
	vector<ll> mesta; mesta.reserve(n);

	loop(i, 0, 2*n+1){
		arr[i]=0;
	}

	loop(i,0,n){
		int temp;
		cin >> temp;
		arr[n+temp]++;
	}

	/*cout << "Array: ";
	loop(i,0,2*n+1){
		cout << arr[i]<< " ";
	}
	cout << "\n";*/

	loop(i,0,2*n+1){
		if(arr[i]>=k){
			br_zamena++;
			mesta.pb(i-n);
		}
	}

	cout << br_zamena<< "\n";
	loop_u(i,0,mesta.size()){
		cout << mesta[i]<< " ";
	}

	return 0;
}