//============================================================================
// Author      : Bissenov Anuar
//============================================================================
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define run_faster ios::sync_with_stdio (false); cin.tie (0); cout.tie (0); ios_base::sync_with_stdio(0); cin.tie(nullptr);
#define F first
#define S second
#define emb emplace_back
#define pii pair<int,int>
#define all(v) (v.begin(),v.end())
#define rall(v) (v.rbegin(),v.rend())
using namespace std;

signed main()
{
    run_faster;
//	#ifndef ONLINE_JUDGE
//        freopen( "inverse.in" , "r" , stdin );
//        freopen( "inverse.out" , "w" , stdout );
//	#endif

    int n, m;
    cin >> n >> m;

    unordered_map<int,int> mp;
    int a;
    vector<int> v;
    for( int i = 1; i <= m; i++ ) {
    	cin >> a;
    	mp[a]++;
    	if( mp[a] == n ) {
    		v.emb(a);
    	}
    }
    cout << v.size() << "\n";
    for( int i: v ) {
    	cout << i << ' ';
    }

    return 0;
} 
