#include <bits/stdc++.h>
using namespace std;
int main() {
int n,k,p;
cin >> n >> k;

int polja[n+1];
int z[n+1];

for( int x = 1 ; x <= n ; x++)
{
    z[x] = n + 1 ;
}

p=0;

for( int x = 1 ; x <= n ; x++)
{
    cin >> polja[x];
}
for( int x = 1 ; x <= n ; x++ )
{
     for( int y = x + 1 ; y <= n ; y++)
     {
         if( polja[x] == polja[y] )
         {
          z[x] = polja[x]; p++;
         }
     }
}

cout << p <<endl;
for( int x = 1 ; x <= n ; x++)
{
if( z[x] != n+1 ) cout << z[x] << " " ;
}



return 0;
}