#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;
   long long a[m];
   long long b[m];
   set <long long> st;
   for(int i=0;i<m;i++){
   	cin>>a[i];
   	b[i] = a[i];
   }
   for(int i=0;i<m;i++){
   	for(int j=0;j<m;j++){
   		if(b[i] == a[j] and i != j){
   			st.insert(b[i]);
		   }
	   }
   }
   cout<<st.size()<<"\n";
   set <long long> :: iterator it;
   for(it = st.begin(); it != st.end(); it++){
   	cout<<*it<<" ";
   }
   
} 

