// BEST TEACHERS: NAZAROV SHARAF and USMONZODA SOMON
//                littbird           another_love
#include <bits/stdc++.h>
 #define ONLINE_JUDGE
#define fi first
#define se second
#define pb push_back
#define yes cout << "YES"
#define no cout << "NO"
#define int long long
#define in insert
#define endl '\n'
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
void solve() {
    // int n,m;
    // cin >> n >> m;
    // int ans = (n * (n + 1) / 2 + n) * ((m + 1) * m / 2);
    // cout << ans;
    int n,m;
    cin >> n >> m;
    vector<int>a(m);
    map<int,int>mp;
    vector<int>ans;
    for(int i =0 ;i < m;i ++){
        cin >> a[i];
        mp[a[i]]++;
        if(mp[a[i]] == n) {
            ans.pb(a[i]);
        }
    }
    cout << ans.size() << endl;
    for(auto i : ans){
        cout << i << " ";
    }

}
signed main() {
#ifndef ONLINE_JUDGE
    // For getting input from input.txt file
    freopen("input.txt", "r", stdin);
    // Printing the Output to output.txt file
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt = 1;
   // cin >> tt;
    for (int q = 1; q <= tt; q++) {
        solve();
        cout << endl;
    }
}
