#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;

const ll mod = 1e9 + 7;
const double pi = 3.14159265359;
const int max_int = 2147483647;
const int INF = (int)(1e9 + 7);
const ll INFLL = (ll)(1e18 + 7);
const long double Pi = acos(-1.0);
const long double Eps = (long double)(1e-12);

int main(){
   speed;
   int n, m;
   cin >> n >> m;
   int a[300000];
   vector<int> cnt(300000);
   vector <int> ans;
   bool was[300000];
   for(int i = 1; i <= m; ++i){
   	 cin >> a[i];
   	 cnt[a[i]] ++;
   }
   for(int 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(int i = 0; i < ans.size(); ++i){
   	 cout << ans[i] << " ";
   }
  
} 

