#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
   
    int n, m; cin >> n >> m;
    map<int, int> used;
    while (m--) {
        int x; cin >> x;
        used[x]++;
    }

    vector<int> ans;
    for (pair<int, int> p : used)
        if (p.second >= n)
            ans.push_back(p.first);
    cout << ans.size() << '\n';
    for (int x : ans)
        cout << x << ' ';
}