

#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define sz(s) (int)s.size()
#define in insert
#define pii pair<int, int>
#define pb push_back

const int MAX=3e5+10;

int n,m;
int a[MAX];
map<int,int> use;

int main(){
   set<int> st;
   cin>>n>>m;
   for(int i=1;i<=m;i++){
    cin>>a[i];
    use[a[i]]++;
    if(use[a[i]]==n)st.in(a[i]);
   } 
   cout<<sz(st)<<"\n";
   for(int x:st)cout<<x<<" ";
}