#include <bits/stdc++.h>

using namespace std;

int brojac=0;
int n,k,a [1007],l=0,m=0;
string d;

int main()
{
    cin>>n>>k;



 for(int i=0;i<n;i++){
    cin>>a[i];

for(int j=0;j<n;j++,l++,m++)

    if((a[i]==a[j]) and i!=j )
        
d[i]=a[i];
        brojac++;
 }
cout<<brojac<<endl;


for(int o=0;o<n;o++)
cout<<d[o]<<" ";

return 0;
}