#include <bits/stdc++.h>

#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx,mmx,tune=native")
#define ll long long
#define pb push_back 
#define f first
#define mp make_pair
using namespace std;

int main(){
   speed;
   ll n, m;
   cin >> n >> m;
   ll a[2000000000];
   vector<ll> cnt(2000000000);
   vector <ll> ans;
   bool was[2000000000];
   for(ll i = 1; i <= m; ++i){
   	 cin >> a[i];
   	 cnt[a[i]] ++;
   }
   for(ll i = 1; i <= m; ++i){
   	if(cnt[a[i]] >= n and !was[a[i]]){
   		ans.push_back(a[i]);
   		was[a[i]] = true;
	   }
   }
   cout << ans.size() << '\n';
   for(ll i = 0; i < ans.size(); ++i){
   	 cout << ans[i] << " ";
   }
  
} 

