//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")


//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include<stack>
#include<string>
#include<string.h>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>


#define ll long long
#define boost ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0)
using namespace std;


int main()
{
 //freopen("input.txt", "r", stdin);
    ///freopen("output.txt", "w", stdout);
 boost;
   ll n,m;
   cin >> n >> m;
   ll a[m + 1];
   map <ll,ll> b;
   ll ans = 0;
   vector <ll> v;
   for(int i = 1;i <= m;i ++)
   {
       cin >> a[i];
          b[a[i]]++;
   }
   sort (a + 1,a + 1 + m);
   ll kk = 0;
   for(int i = 1;i <= m;i ++)
   {
    
       if(b[a[i]] >= n && a[i] != kk){
        kk = a[i];
        ans ++;
        v.push_back(a[i]);
       }
   }
   cout << ans << endl ;
   for(int i = 0;i < v.size();i++)
   {
       cout << v[i] << " ";
   }
   
   
}