#include "bits/stdc++.h"


#define OPEN  freopen ("ancestor","r" , stdin), freopen ("ancestor","w",stdout);
#define Da ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define p_b push_back
#define max1(a,b,c) max(a,max(b,c))
#define min1(a,b,c) min(a,min(b,c))
#define all(a) a.begin() , a.end() 
#define aza cout<<" ? "<<endl;//>>>>
#define F first
#define S second
#define co continue
#define endl '\n'    
#define pre precision
using namespace std;
const long long N=1e7+9,MOD=1e9+7;
map<long long,long long> mp;
main(){
  Da
  long long n,m;
  cin>>n>>m;
  long long a[m+1],sum=0;
  vector<long long> v;
  for(int i=1;i<=m;i++){
    cin>>a[i];
    if(a[i]>=n){
      mp[a[i]]++;
      if(mp[a[i]]>=n){
        v.p_b(a[i]);
        mp[a[i]]=-1e9;
        sum++;
      }
    }
  }
  cout<<sum<<endl;//>>>>
  for(int i=0;i<v.size();i++){
    cout<<v[i]<<' ';//>>>>
  }
}