#include <bits/stdc++.h>
#define S second
#define F first
#define int long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define yes "YES"
#define no "NO"
#define ent "\n"
#define rv reverse
#define fr(i,x,y) for(int i = x;i <= y;i++)
#define frr(i,x,y) for(int i = x;i >= y;i--)
using namespace std;

const int mod = 1e9 + 7,maxn = 1e5 + 5;

map <int , int> mp,mpp;
vector <int> v;

void solve() {
	int n,m;
	cin>>n>>m;
	int a[m + 5];
	int mx = 0;
	fr(i,1,m){
		cin>>a[i];
		mp[a[i]]++;
	}
	fr(i,1,m){
		if(mp[a[i]] > 1 && mpp[a[i]] == 0){
			v.pb(a[i]);
			mpp[a[i]] = 1;
		}
	}
	cout<<v.size()<<ent;
	for(auto to : v){
		cout<<to<<' ';
	}
}

signed main() {
	//freopen ("bridges.in","r",stdin);
	//freopen ("bridges.out","w",stdout);
	int t = 1;
	//cin>>t;
	while(t--) {
		solve();
	}
}
