#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m  , k = 0;
cin>>n>>m;
int a[m] ;
vector<int> s(k);
for(int i = 0 ; i < m ; i++){
    cin>>a[i];//1 3 6 5 3 2 4 5 3 2
}
sort(a,a+m);//1 2 2 3 3 3 4 5 5 6
for(int i = 0  ; i < m ;  i++){
    if(a[i+n-1]==a[i]){
        s.push_back(a[i]);
        k++;}
    while(a[i]==a[i+1]){
        i++;
    }
}
cout<<k<<endl;
for(int j = 0  ; j < k ; j ++){
    cout<<s[j]<<" ";
}
}
