#include <bits/stdc++.h>

using namespace std;
using ll = long long;

signed main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
    int n, m, x;
    cin >> n >> m;
    set<int> v;
    map<int, int> cnt;
    for (int i = 0; i < m; i++) {
        cin >> x;
        cnt[x]++;
        if (cnt[x] >= n) {
            v.insert(x);
        }
    }
    cout << v.size() << "\n";
    for (auto i : v)
        cout << i << " ";
}