//deo koda uzet sa sajta : https://www.geeksforgeeks.org/counting-frequencies-of-array-elements/
#include <bits/stdc++.h>
using namespace std;
void countFreq(int arr[], int n, int k) {
    int brojac=0;
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++)
        mp[arr[i]]++;
    for (auto x : mp) {
        if(x.second>=k){
            brojac++;
            }
    }
    cout<<brojac<<endl;
for (auto x : mp) {
    if(x.second>=k){
    cout << x.first << " ";
}
}
}
int main() {
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0; i<n; i++){
cin>>arr[i];
        }
    countFreq(arr, n, k);
    return 0;
}