#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast") //~ only for that moment
#define all(x) (x).begin(), (x).end()
#define ImOnASugarCrash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz(x) int((x).size())
template<typename... Args>
void read(Args&... args) {
    ((std::cin >> args), ...);
}
using ll = long long;
using ld = long double;
//!


signed main() {
    ImOnASugarCrash();    
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    set<int> res;
    for (int i = 0; i < m; i ++) {
        int a; cin >> a;
    	mp[a] ++;
    	if (mp[a] >= n) res.insert(a);
    }
    cout << sz(res) << "\n";
    for (auto i : res) cout << i << " ";
}