/*
   (( '-""``""-' ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / ;#'#'# - #'#'#; \
 \_)) -----'#'----- ((_/
      # --------- #
      '# ------- #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))
    art by - Vinni01 / luchi abi
 
    cout << fixed << setprecision(6) << x;
    freopen ( "sum.in", "r", stdin )
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std ;
#define ll int
#define ff first
#define ss second
#define pb push_back 
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0)
#define sz size
#define ins insert
#define new jweijofdg
const ll N = 3e5 + 111 ;
const ll k = 400 ;
vector < ll > g[ N ] ;
//ll a[ N ] ;
bool used[ N ] ;
ll p[ N ] ;
ll timer ;
ll tin[ N ] ;
//vector < pair < ll, ll > > g ;
ll t[ N + N + N + N ] ; 
ll a[ N ] ;
bool b = 0 ;
bool ok ;
ll X = 0, Y = 0 ;
map < ll, ll > cnt ;
signed main()
{
 ll n, m ;
 cin >> n >> m ;
 set < ll > st ;
 for( int i = 1 ; i <= m ; i++ )
 {
  cin >> a[ i ] ;
  cnt[ a[ i ] ]++ ;
  if( cnt[ a[ i ] ] == n )
  {
   st.ins( a[ i ] ) ;
  }
 }
 cout << st.sz() << '\n' ;
 for( auto to : st ) cout << to << " " ;
}
// ?? ??? ??? ??? ?????? ??? ??? ?? ???????? Dua Yunus

// Ля иляха илля Анта! Субханака, инни кунту мина-з-залимин!

// ????? ??????? ??? ??????? * ????????? ??? ??????? * ????????? ???????? ???? ???????? * ?????????? ???????

//Рабби-шра? ли cадри, ва яссир ли амри, ва?люль ‘у?датан мин лисани, яф?аhу ?авли

//Dua for studying
